mirror of https://github.com/status-im/nim-eth.git
Quick fix for when removePeer gets called before dispatcher is initialized
This commit is contained in:
parent
7cdd31e982
commit
5d9239ef17
|
@ -1122,10 +1122,13 @@ proc removePeer(network: EthereumNode, peer: Peer) =
|
||||||
if network.peerPool != nil and not peer.remote.isNil:
|
if network.peerPool != nil and not peer.remote.isNil:
|
||||||
network.peerPool.connectedNodes.del(peer.remote)
|
network.peerPool.connectedNodes.del(peer.remote)
|
||||||
|
|
||||||
for observer in network.peerPool.observers.values:
|
# Note: we need to do this check as disconnect (and thus removePeer)
|
||||||
if not observer.onPeerDisconnected.isNil:
|
# currently can get called before the dispatcher is initialized.
|
||||||
if observer.protocol.isNil or peer.supports(observer.protocol):
|
if not peer.dispatcher.isNil:
|
||||||
observer.onPeerDisconnected(peer)
|
for observer in network.peerPool.observers.values:
|
||||||
|
if not observer.onPeerDisconnected.isNil:
|
||||||
|
if observer.protocol.isNil or peer.supports(observer.protocol):
|
||||||
|
observer.onPeerDisconnected(peer)
|
||||||
|
|
||||||
proc callDisconnectHandlers(peer: Peer, reason: DisconnectionReason): Future[void] =
|
proc callDisconnectHandlers(peer: Peer, reason: DisconnectionReason): Future[void] =
|
||||||
var futures = newSeqOfCap[Future[void]](allProtocols.len)
|
var futures = newSeqOfCap[Future[void]](allProtocols.len)
|
||||||
|
|
Loading…
Reference in New Issue