Quick fix for when removePeer gets called before dispatcher is initialized

This commit is contained in:
kdeme 2019-04-18 14:33:38 +02:00
parent 7cdd31e982
commit 5d9239ef17
1 changed files with 7 additions and 4 deletions

View File

@ -1122,6 +1122,9 @@ proc removePeer(network: EthereumNode, peer: Peer) =
if network.peerPool != nil and not peer.remote.isNil:
network.peerPool.connectedNodes.del(peer.remote)
# Note: we need to do this check as disconnect (and thus removePeer)
# currently can get called before the dispatcher is initialized.
if not peer.dispatcher.isNil:
for observer in network.peerPool.observers.values:
if not observer.onPeerDisconnected.isNil:
if observer.protocol.isNil or peer.supports(observer.protocol):