Commit b9be98f0 authored by szh's avatar szh

up

parent e3111040
......@@ -40,3 +40,6 @@ Password =
MaxIdle = 30
MaxActive = 30
IdleTimeout = 200
[block]
Host = 127.0.0.1:8802
\ No newline at end of file
......@@ -9,7 +9,9 @@ import (
"chain33-pai/pkg/logging"
"chain33-pai/pkg/setting"
"chain33-pai/routers"
"chain33-pai/models"
"chain33-pai/pkg/util"
"chain33-pai/pkg/chain33"
"net"
"time"
"chain33-pai/service/pai_service"
......@@ -17,9 +19,10 @@ import (
func init() {
setting.Setup()
//models.Setup()
models.Setup()
logging.Setup()
//gredis.Setup()
chain33.Setup()
util.Setup()
}
......
package miner
func init() {
}
func SyncBlock() {
}
......@@ -4,6 +4,7 @@ import (
"github.com/33cn/chain33/types"
"google.golang.org/grpc"
"context"
"chain33-pai/pkg/setting"
)
type PaiClient struct {
......@@ -15,9 +16,9 @@ var (
paiNetgrpcAddr = "localhost:8802"
)
func init() {
func Setup() {
maxReceLimit := grpc.WithMaxMsgSize(30*1024*1024)
conn, err := grpc.Dial(paiNetgrpcAddr, grpc.WithInsecure(),maxReceLimit)
conn, err := grpc.Dial(setting.BlockSetting.Host, grpc.WithInsecure(),maxReceLimit)
if err != nil {
panic(err)
}
......@@ -39,3 +40,20 @@ func (p *PaiClient) IsNtpClockSync() (*types.Reply,error) {
func (p *PaiClient) GetNetInfo() (*types.NodeNetInfo,error) {
return paiClient.NetInfo(context.Background(),&types.ReqNil{})
}
func (p *PaiClient) GetBlocks(req *types.ReqBlocks) (*types.BlockDetails,error) {
var detail types.BlockDetails
reply,err := paiClient.GetBlocks(context.Background(),req)
if err != nil {
return nil,err
}
err = types.Decode(reply.Msg,&detail)
if err != nil {
return nil,err
}
return &detail,nil
}
func (p *PaiClient) GetLastHeader() (*types.Header,error) {
return paiClient.GetLastHeader(context.Background(),&types.ReqNil{})
}
\ No newline at end of file
......@@ -60,6 +60,12 @@ type Redis struct {
var RedisSetting = &Redis{}
type block struct {
Host string
}
var BlockSetting = &block{}
var cfg *ini.File
// Setup initialize the configuration instance
......@@ -74,6 +80,7 @@ func Setup() {
mapTo("server", ServerSetting)
mapTo("database", DatabaseSetting)
mapTo("redis", RedisSetting)
mapTo("block",BlockSetting)
AppSetting.ImageMaxSize = AppSetting.ImageMaxSize * 1024 * 1024
ServerSetting.ReadTimeout = ServerSetting.ReadTimeout * time.Second
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment