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