From 78ec80eea0807c30590ad36710b043c96d2fd61d Mon Sep 17 00:00:00 2001 From: Kim De Mey Date: Mon, 11 Dec 2023 11:53:32 +0100 Subject: [PATCH] Add trace logs when ENR gets added to portal network routing table (#1932) --- fluffy/network/wire/portal_protocol.nim | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/fluffy/network/wire/portal_protocol.nim b/fluffy/network/wire/portal_protocol.nim index 3ef289d7a..303fbd511 100644 --- a/fluffy/network/wire/portal_protocol.nim +++ b/fluffy/network/wire/portal_protocol.nim @@ -440,7 +440,7 @@ proc handleOffer(p: PortalProtocol, o: OfferMessage, srcId: NodeId): seq[byte] = AcceptMessage(connectionId: connectionId, contentKeys: contentKeysBitList)) proc messageHandler(protocol: TalkProtocol, request: seq[byte], - srcId: NodeId, srcUdpAddress: Address, node: Opt[Node]): seq[byte] = + srcId: NodeId, srcUdpAddress: Address, nodeOpt: Opt[Node]): seq[byte] = doAssert(protocol of PortalProtocol) logScope: @@ -462,12 +462,18 @@ proc messageHandler(protocol: TalkProtocol, request: seq[byte], # exists on the base layer, and it will also depend on the distance, # order of lookups, etc. # Note: As third measure, could run a findNodes request with distance 0. - if node.isSome(): - discard p.addNode(node.get()) + if nodeOpt.isSome(): + let node = nodeOpt.value() + let status = p.addNode(node) + trace "Adding new node to routing table after incoming request", + status, node else: - let node = p.baseProtocol.getNode(srcId) - if node.isSome(): - discard p.addNode(node.get()) + let nodeOpt = p.baseProtocol.getNode(srcId) + if nodeOpt.isSome(): + let node = nodeOpt.value() + let status = p.addNode(node) + trace "Adding new node to routing table after incoming request", + status, node portal_message_requests_incoming.inc( labelValues = [$p.protocolId, $message.kind])