Commit 46eb1c28 authored by suyanlong's avatar suyanlong

Fixed peer connection bug

parent 9dd896aa
Pipeline #7989 canceled with stages
...@@ -35,22 +35,22 @@ report_caller = false ...@@ -35,22 +35,22 @@ report_caller = false
#tlsca = "certs/ca.pem" #tlsca = "certs/ca.pem"
#common_name = "localhost" #common_name = "localhost"
[[appchain]] #[[appchain]]
enable = true #enable = true
type = "appchain" #type = "appchain"
did = "did:bitxhub:fabappchain:." #did = "did:bitxhub:fabappchain:."
plugin = "appchain_plugin" #plugin = "appchain_plugin"
config = "fabric" #config = "fabric"
#
[[appchain]] #[[appchain]]
enable = true #enable = true
type = "hub" #type = "hub"
did = "did:bitxhub:chain33:." #did = "did:bitxhub:chain33:."
plugin = "appchain_plugin" #plugin = "appchain_plugin"
config = "chain33" #config = "chain33"
[peer] [peer]
peers = ["localhost:60011", "localhost:60012", "localhost:60013", "localhost:60014"] peers = ["/ip4/127.0.0.1/tcp/4000/p2p/QmYwuTi2MCEF39mjK9EnARPjY3RRaapBatqU67znK2c1Nm","/ip4/127.0.0.1/tcp/4001/ipfs/QmfC33rPPobCDo1WBhAy8VG6ocTiLfZzFb8aaQGqv3MVv3","/ip4/127.0.0.1/tcp/4002/ipfs/QmVtRucwZjzLb2AEd4CRZ2nheLrDEuUymG8zKsfxdg2pic"]
connectors = [] connectors = ["localhost:60011", "localhost:60012", "localhost:60013", "localhost:60014"]
providers = 1 providers = 1
...@@ -13,22 +13,22 @@ import ( ...@@ -13,22 +13,22 @@ import (
type Manager struct { type Manager struct {
logger logrus.FieldLogger logger logrus.FieldLogger
Mgr appchainmgr.AppchainMgr appchainMgr appchainmgr.AppchainMgr
pm peermgr.PeerManager pm peermgr.PeerManager
router router.Router router router.Router
} }
func (mgr *Manager) Start() error { func (mgr *Manager) Start() error {
panic("implement me") return mgr.pm.Start()
} }
func (mgr *Manager) Stop() error { func (mgr *Manager) Stop() error {
panic("implement me") return mgr.pm.Stop()
} }
func NewManager(addr string, router router.Router, pm peermgr.PeerManager, Mgr appchainmgr.AppchainMgr, logger logrus.FieldLogger) (*Manager, error) { func NewManager(addr string, router router.Router, pm peermgr.PeerManager, Mgr appchainmgr.AppchainMgr, logger logrus.FieldLogger) (*Manager, error) {
am := &Manager{ am := &Manager{
Mgr: Mgr, appchainMgr: Mgr,
logger: logger, logger: logger,
router: router, router: router,
pm: pm, pm: pm,
...@@ -51,16 +51,16 @@ func (mgr *Manager) handleMessage(s port.Port, msg *pb.Message) { ...@@ -51,16 +51,16 @@ func (mgr *Manager) handleMessage(s port.Port, msg *pb.Message) {
var ok bool var ok bool
switch msg.Type { switch msg.Type {
case pb.Message_APPCHAIN_REGISTER: case pb.Message_APPCHAIN_REGISTER:
ok, res = mgr.Mgr.Register(msg.Payload.Data) ok, res = mgr.appchainMgr.Register(msg.Payload.Data)
case pb.Message_APPCHAIN_UPDATE: case pb.Message_APPCHAIN_UPDATE:
ok, res = mgr.Mgr.Update(msg.Payload.Data) ok, res = mgr.appchainMgr.Update(msg.Payload.Data)
case pb.Message_APPCHAIN_GET: case pb.Message_APPCHAIN_GET:
app := &appchainmgr.Appchain{} app := &appchainmgr.Appchain{}
if err := json.Unmarshal(msg.Payload.Data, app); err != nil { if err := json.Unmarshal(msg.Payload.Data, app); err != nil {
mgr.logger.Error(err) mgr.logger.Error(err)
return return
} }
ok, res = mgr.Mgr.QueryById(app.ID, nil) ok, res = mgr.appchainMgr.QueryById(app.ID, nil)
default: default:
m := "wrong appchain message type" m := "wrong appchain message type"
res = []byte(m) res = []byte(m)
......
...@@ -109,26 +109,26 @@ func DefaultConfig() *Config { ...@@ -109,26 +109,26 @@ func DefaultConfig() *Config {
}, },
}, },
Peer: Peer{ Peer: Peer{
Peers: []string{"localhost:60011", "localhost:60012", "localhost:60013", "localhost:60014"}, Peers: []string{},
Connectors: []string{}, Connectors: []string{},
Providers: 1, Providers: 1,
}, },
Appchains: Appchains{[]Appchain{ //Appchains: Appchains{[]Appchain{
{ // {
Enable: true, // Enable: true,
Type: "appchain", // Type: "appchain",
DID: "did:bitxhub:appchain:.", // DID: "did:bitxhub:appchain:.",
Plugin: "appchain_plugin", // Plugin: "appchain_plugin",
Config: "fabric", // Config: "fabric",
}, // },
{ // {
Enable: true, // Enable: true,
Type: "hub", // Type: "hub",
DID: "did:bitxhub:chain33:.", // DID: "did:bitxhub:chain33:.",
Plugin: "appchain_plugin", // Plugin: "appchain_plugin",
Config: "chain33", // Config: "chain33",
}, // },
}}, //}},
} }
} }
......
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