diff --git a/codexdht/private/eth/p2p/discoveryv5/protocol.nim b/codexdht/private/eth/p2p/discoveryv5/protocol.nim index 17398c1..a204ee5 100644 --- a/codexdht/private/eth/p2p/discoveryv5/protocol.nim +++ b/codexdht/private/eth/p2p/discoveryv5/protocol.nim @@ -411,6 +411,13 @@ proc handleGetProviders( proc handleMessage(d: Protocol, srcId: NodeId, fromAddr: Address, message: Message) = + + if message.clientMode: + let node = d.routingTable.getNode(srcId) + if node.isSome: + d.routingTable.removeNode(node.get) + trace "Node removed from routing table after handling message", srcId + case message.kind of ping: dht_message_requests_incoming.inc() @@ -445,12 +452,6 @@ proc handleMessage(d: Protocol, srcId: NodeId, fromAddr: Address, trace "Timed out or unrequested message", kind = message.kind, origin = fromAddr - if message.clientMode: - let node = d.routingTable.getNode(srcId) - if node.isSome: - d.routingTable.removeNode(node.get) - trace "Node removed from routing table after handling message", srcId - proc registerTalkProtocol*(d: Protocol, protocolId: seq[byte], protocol: TalkProtocol): DiscResult[void] = # Currently allow only for one handler per talk protocol.