Skip to content

Commit

Permalink
fix(dot/network): add nil checks in connManager (#2069)
Browse files Browse the repository at this point in the history
  • Loading branch information
noot committed Nov 25, 2021
1 parent 2f62832 commit 7f9c042
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions dot/network/connmgr.go
Expand Up @@ -130,7 +130,9 @@ func (cm *ConnManager) unprotectedPeers(peers []peer.ID) []peer.ID {
func (cm *ConnManager) Connected(n network.Network, c network.Conn) {
logger.Tracef(
"Host %s connected to peer %s", n.LocalPeer(), c.RemotePeer())
cm.connectHandler(c.RemotePeer())
if cm.connectHandler != nil {
cm.connectHandler(c.RemotePeer())
}

cm.Lock()
defer cm.Unlock()
Expand Down Expand Up @@ -169,7 +171,9 @@ func (cm *ConnManager) Disconnected(_ network.Network, c network.Conn) {
logger.Tracef("Host %s disconnected from peer %s", c.LocalPeer(), c.RemotePeer())

cm.Unprotect(c.RemotePeer(), "")
cm.disconnectHandler(c.RemotePeer())
if cm.disconnectHandler != nil {
cm.disconnectHandler(c.RemotePeer())
}
}

// OpenedStream is called when a stream is opened
Expand Down

0 comments on commit 7f9c042

Please sign in to comment.