Fix segfault when there is no peer_pool (no connectToNetwork() ran).
e.g. tserver test would segfault.
This commit is contained in:
parent
19cd8201b0
commit
f62ca5607d
17
eth_p2p.nim
17
eth_p2p.nim
|
@ -58,14 +58,15 @@ proc processIncoming(server: StreamServer,
|
|||
yield peerfut
|
||||
if not peerfut.failed:
|
||||
let peer = peerfut.read()
|
||||
if peer.remote notin node.peerPool.connectedNodes:
|
||||
node.peerPool.connectedNodes[peer.remote] = peer
|
||||
for o in node.peerPool.observers.values:
|
||||
if not o.onPeerConnected.isNil:
|
||||
o.onPeerConnected(peer)
|
||||
else:
|
||||
debug "Disconnecting already connected node"
|
||||
await peer.disconnect(AlreadyConnected)
|
||||
if node.peerPool != nil:
|
||||
if peer.remote notin node.peerPool.connectedNodes:
|
||||
node.peerPool.connectedNodes[peer.remote] = peer
|
||||
for o in node.peerPool.observers.values:
|
||||
if not o.onPeerConnected.isNil:
|
||||
o.onPeerConnected(peer)
|
||||
else:
|
||||
debug "Disconnecting already connected node"
|
||||
await peer.disconnect(AlreadyConnected)
|
||||
else:
|
||||
remote.close()
|
||||
|
||||
|
|
Loading…
Reference in New Issue