Commit b9be98f0 authored by szh's avatar szh

up

parent e3111040
...@@ -39,4 +39,7 @@ Host = 127.0.0.1:6379 ...@@ -39,4 +39,7 @@ Host = 127.0.0.1:6379
Password = Password =
MaxIdle = 30 MaxIdle = 30
MaxActive = 30 MaxActive = 30
IdleTimeout = 200 IdleTimeout = 200
\ No newline at end of file
[block]
Host = 127.0.0.1:8802
\ No newline at end of file
...@@ -9,7 +9,9 @@ import ( ...@@ -9,7 +9,9 @@ import (
"chain33-pai/pkg/logging" "chain33-pai/pkg/logging"
"chain33-pai/pkg/setting" "chain33-pai/pkg/setting"
"chain33-pai/routers" "chain33-pai/routers"
"chain33-pai/models"
"chain33-pai/pkg/util" "chain33-pai/pkg/util"
"chain33-pai/pkg/chain33"
"net" "net"
"time" "time"
"chain33-pai/service/pai_service" "chain33-pai/service/pai_service"
...@@ -17,9 +19,10 @@ import ( ...@@ -17,9 +19,10 @@ import (
func init() { func init() {
setting.Setup() setting.Setup()
//models.Setup() models.Setup()
logging.Setup() logging.Setup()
//gredis.Setup() //gredis.Setup()
chain33.Setup()
util.Setup() util.Setup()
} }
......
package miner
func init() {
}
func SyncBlock() {
}
...@@ -4,6 +4,7 @@ import ( ...@@ -4,6 +4,7 @@ import (
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
"google.golang.org/grpc" "google.golang.org/grpc"
"context" "context"
"chain33-pai/pkg/setting"
) )
type PaiClient struct { type PaiClient struct {
...@@ -15,9 +16,9 @@ var ( ...@@ -15,9 +16,9 @@ var (
paiNetgrpcAddr = "localhost:8802" paiNetgrpcAddr = "localhost:8802"
) )
func init() { func Setup() {
maxReceLimit := grpc.WithMaxMsgSize(30*1024*1024) 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 { if err != nil {
panic(err) panic(err)
} }
...@@ -38,4 +39,21 @@ func (p *PaiClient) IsNtpClockSync() (*types.Reply,error) { ...@@ -38,4 +39,21 @@ func (p *PaiClient) IsNtpClockSync() (*types.Reply,error) {
func (p *PaiClient) GetNetInfo() (*types.NodeNetInfo,error) { func (p *PaiClient) GetNetInfo() (*types.NodeNetInfo,error) {
return paiClient.NetInfo(context.Background(),&types.ReqNil{}) 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 { ...@@ -60,6 +60,12 @@ type Redis struct {
var RedisSetting = &Redis{} var RedisSetting = &Redis{}
type block struct {
Host string
}
var BlockSetting = &block{}
var cfg *ini.File var cfg *ini.File
// Setup initialize the configuration instance // Setup initialize the configuration instance
...@@ -74,6 +80,7 @@ func Setup() { ...@@ -74,6 +80,7 @@ func Setup() {
mapTo("server", ServerSetting) mapTo("server", ServerSetting)
mapTo("database", DatabaseSetting) mapTo("database", DatabaseSetting)
mapTo("redis", RedisSetting) mapTo("redis", RedisSetting)
mapTo("block",BlockSetting)
AppSetting.ImageMaxSize = AppSetting.ImageMaxSize * 1024 * 1024 AppSetting.ImageMaxSize = AppSetting.ImageMaxSize * 1024 * 1024
ServerSetting.ReadTimeout = ServerSetting.ReadTimeout * time.Second 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