nim-eth icon indicating copy to clipboard operation
nim-eth copied to clipboard

Run only onPeerDisconnected for subprotocols that had onPeerConnected ran.

Open kdeme opened this issue 6 years ago • 0 comments

Currently, if one of the subprotocol onPeerConnected calls fails (exception raised) this will be catched in rlpxConnect/rlpxAccept and the peer will get disconnected (UselessPeer).

Before this happens, all others subprotocol onPeerConnected calls will be ran though. However, the onPeerDisconnected calls are never run. Possibly creating problems if they should have cleaned up certain resources/loops.

This could be added easily, but then also the onPeerDisconnected call of the failing subprotocol would be run, potentially causing other problems.

In short, best would be to have only onPeerDisconnected ran for those subprotocols that succesfully had onPeerConnected ran.

This used to be a potential problem for whisper_protocol but got solved like this: https://github.com/status-im/nim-eth/pull/62

But I think it could still be a problem for les_protocol: https://github.com/status-im/nim-eth/blob/master/eth/p2p/rlpx_protocols/les_protocol.nim#L249

kdeme avatar Jun 12 '19 13:06 kdeme