Move the client mode check at the beginning of the proc

This commit is contained in:
Arnaud 2026-05-14 09:10:13 +04:00
parent f43580c713
commit 0f4c509ef3
No known key found for this signature in database
GPG Key ID: A6C7C781817146FA

View File

@ -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.