From 25b0da02801a216fe7fc8cba5aaf0d5c0138e267 Mon Sep 17 00:00:00 2001 From: Kim De Mey Date: Tue, 18 Apr 2023 13:51:02 +0200 Subject: [PATCH] Fix JSON writer for logging in devp2p code (#597) --- eth/p2p/discovery.nim | 2 +- eth/p2p/enode.nim | 4 ++++ eth/p2p/kademlia.nim | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/eth/p2p/discovery.nim b/eth/p2p/discovery.nim index 44ed4a9..6c85e52 100644 --- a/eth/p2p/discovery.nim +++ b/eth/p2p/discovery.nim @@ -138,7 +138,7 @@ proc sendNeighbours*(d: DiscoveryProtocol, node: Node, neighbours: seq[Node]) = block: let payload = rlp.encode((nodes, expiration())) let msg = pack(cmdNeighbours, payload, d.privKey) - trace "Neighbours to", node, nodes + trace "Neighbours to", node, nodes = $nodes d.send(node, msg) nodes.setLen(0) diff --git a/eth/p2p/enode.nim b/eth/p2p/enode.nim index 9cef3d9..67df0e1 100644 --- a/eth/p2p/enode.nim +++ b/eth/p2p/enode.nim @@ -12,6 +12,7 @@ import std/[uri, strutils, net], + pkg/chronicles, ../keys export keys @@ -133,3 +134,6 @@ proc `$`*(a: Address): string = result.add($a.ip) result.add(":" & $a.udpPort) result.add(":" & $a.tcpPort) + +chronicles.formatIt(Address): $it +chronicles.formatIt(ENode): $it diff --git a/eth/p2p/kademlia.nim b/eth/p2p/kademlia.nim index 0ec3324..af173a3 100644 --- a/eth/p2p/kademlia.nim +++ b/eth/p2p/kademlia.nim @@ -95,6 +95,9 @@ proc `$`*(n: Node): string = else: "Node[" & $n.node.address.ip & ":" & $n.node.address.udpPort & "]" +chronicles.formatIt(Node): $it +chronicles.formatIt(seq[Node]): $it + proc hash*(n: Node): hashes.Hash = hash(n.node.pubkey.toRaw) proc `==`*(a, b: Node): bool = (a.isNil and b.isNil) or (not a.isNil and not b.isNil and a.node.pubkey == b.node.pubkey)