Commit a00052d2 authored by suyanlong's avatar suyanlong

Fix panic bug

parent 1ccbb26f
Pipeline #8410 failed with stages
...@@ -49,17 +49,15 @@ func New(config *repo.Config, router router.Router, nodePrivKey crypto.PrivateKe ...@@ -49,17 +49,15 @@ func New(config *repo.Config, router router.Router, nodePrivKey crypto.PrivateKe
if err != nil { if err != nil {
return nil, fmt.Errorf("convert private key: %w", err) return nil, fmt.Errorf("convert private key: %w", err)
} }
var ll string
var remotes map[string]*peer.AddrInfo
id, err := peer.IDFromPrivateKey(libp2pPrivKey) id, err := peer.IDFromPrivateKey(libp2pPrivKey)
if err != nil { if err != nil {
panic(err) return nil, err
} }
local := newLocal(id, privKey) local := newLocal(id, privKey)
ll, remotes, err = loadPeers(config.Peer.Peers, libp2pPrivKey) ll, remotes, err := loadPeers(config.Peer.Peers, libp2pPrivKey)
if err != nil { if err != nil {
return nil, fmt.Errorf("load peers: %w", err) return nil, fmt.Errorf("load peers: %w", err)
} }
...@@ -246,11 +244,7 @@ func (swarm *Swarm) Stop() error { ...@@ -246,11 +244,7 @@ func (swarm *Swarm) Stop() error {
return err return err
} }
swarm.cancel() swarm.cancel()
err := swarm.router.Stop() return swarm.router.Stop()
if err != nil {
return err
}
return nil
} }
func (swarm *Swarm) Connect(addrInfo *peer.AddrInfo) (string, error) { func (swarm *Swarm) Connect(addrInfo *peer.AddrInfo) (string, error) {
......
...@@ -21,8 +21,8 @@ func NewPortMap() *PortMap { ...@@ -21,8 +21,8 @@ func NewPortMap() *PortMap {
rw: sync.RWMutex{}, rw: sync.RWMutex{},
peerPort: map[string]Port{}, peerPort: map[string]Port{},
appchainPort: map[string]Port{}, appchainPort: map[string]Port{},
hubPort: nil, hubPort: nil, //TODO
local: nil, local: nil, //TODO
} }
} }
......
...@@ -21,11 +21,6 @@ type Router interface { ...@@ -21,11 +21,6 @@ type Router interface {
Send(id string, msg *pb.Message) (*pb.Message, error) Send(id string, msg *pb.Message) (*pb.Message, error)
AsyncSend(id string, msg *pb.Message) error AsyncSend(id string, msg *pb.Message) error
// InPut(ibtp *pb.IBTP) chan *pb.IBTP
// OutPut(ibtp *pb.IBTP) chan *pb.IBTP
// 代替上面两个方法
// Router(ibtp *pb.IBTP) chan *pb.IBTP
} }
// 路由规则,根据路由表,rules接口, 这个放到交易内部。可以让用户决定。并且签名。 // 路由规则,根据路由表,rules接口, 这个放到交易内部。可以让用户决定。并且签名。
......
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