From 62e2ea32f0f90a2a5402cde5468a230f44420a84 Mon Sep 17 00:00:00 2001 From: noot Date: Wed, 24 Nov 2021 13:09:15 -0500 Subject: [PATCH] add nil checks in connManager --- dot/network/connmgr.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dot/network/connmgr.go b/dot/network/connmgr.go index 9f7e257d73..d9cabfc9dc 100644 --- a/dot/network/connmgr.go +++ b/dot/network/connmgr.go @@ -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() @@ -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