server.go: log DisconnectPeer errors, use public functions to access
peer internals.
This commit is contained in:
parent
bfaef46579
commit
ac72479b10
25
server.go
25
server.go
@ -1481,7 +1481,13 @@ func (s *server) Stop() error {
|
||||
// Disconnect from each active peers to ensure that
|
||||
// peerTerminationWatchers signal completion to each peer.
|
||||
for _, peer := range s.Peers() {
|
||||
s.DisconnectPeer(peer.addr.IdentityKey)
|
||||
err := s.DisconnectPeer(peer.IdentityKey())
|
||||
if err != nil {
|
||||
srvrLog.Warnf("could not disconnect peer: %v"+
|
||||
"received error: %v", peer.IdentityKey(),
|
||||
err,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Now that all connections have been torn down, stop the tower
|
||||
@ -1820,7 +1826,7 @@ func (s *server) peerBootstrapper(numTargetPeers uint32,
|
||||
s.mu.RLock()
|
||||
ignoreList := make(map[autopilot.NodeID]struct{})
|
||||
for _, peer := range s.peersByPub {
|
||||
nID := autopilot.NewNodeID(peer.addr.IdentityKey)
|
||||
nID := autopilot.NewNodeID(peer.IdentityKey())
|
||||
ignoreList[nID] = struct{}{}
|
||||
}
|
||||
s.mu.RUnlock()
|
||||
@ -2313,9 +2319,9 @@ func (s *server) BroadcastMessage(skips map[route.Vertex]struct{},
|
||||
peers := make([]*peer, 0, len(s.peersByPub))
|
||||
for _, sPeer := range s.peersByPub {
|
||||
if skips != nil {
|
||||
if _, ok := skips[sPeer.pubKeyBytes]; ok {
|
||||
if _, ok := skips[sPeer.PubKey()]; ok {
|
||||
srvrLog.Tracef("Skipping %x in broadcast",
|
||||
sPeer.pubKeyBytes[:])
|
||||
sPeer.PubKey())
|
||||
continue
|
||||
}
|
||||
}
|
||||
@ -2905,7 +2911,7 @@ func (s *server) peerInitializer(p *peer) {
|
||||
// was successful, and to begin watching the peer's wait group.
|
||||
close(ready)
|
||||
|
||||
pubStr := string(p.addr.IdentityKey.SerializeCompressed())
|
||||
pubStr := string(p.IdentityKey().SerializeCompressed())
|
||||
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
@ -2952,7 +2958,7 @@ func (s *server) peerTerminationWatcher(p *peer, ready chan struct{}) {
|
||||
// available for use.
|
||||
s.fundingMgr.CancelPeerReservations(p.PubKey())
|
||||
|
||||
pubKey := p.addr.IdentityKey
|
||||
pubKey := p.IdentityKey()
|
||||
|
||||
// We'll also inform the gossiper that this peer is no longer active,
|
||||
// so we don't need to maintain sync state for it any longer.
|
||||
@ -2963,13 +2969,13 @@ func (s *server) peerTerminationWatcher(p *peer, ready chan struct{}) {
|
||||
// with this interface should be closed.
|
||||
//
|
||||
// TODO(roasbeef): instead add a PurgeInterfaceLinks function?
|
||||
links, err := p.server.htlcSwitch.GetLinksByInterface(p.pubKeyBytes)
|
||||
links, err := s.htlcSwitch.GetLinksByInterface(p.PubKey())
|
||||
if err != nil && err != htlcswitch.ErrNoLinksFound {
|
||||
srvrLog.Errorf("Unable to get channel links for %v: %v", p, err)
|
||||
}
|
||||
|
||||
for _, link := range links {
|
||||
p.server.htlcSwitch.RemoveLink(link.ChanID())
|
||||
s.htlcSwitch.RemoveLink(link.ChanID())
|
||||
}
|
||||
|
||||
s.mu.Lock()
|
||||
@ -3124,7 +3130,8 @@ func (s *server) removePeer(p *peer) {
|
||||
return
|
||||
}
|
||||
|
||||
pubSer := p.addr.IdentityKey.SerializeCompressed()
|
||||
pKey := p.PubKey()
|
||||
pubSer := pKey[:]
|
||||
pubStr := string(pubSer)
|
||||
|
||||
delete(s.peersByPub, pubStr)
|
||||
|
Loading…
Reference in New Issue
Block a user