Fix JSON writer for logging in devp2p code (#597)

This commit is contained in:
Kim De Mey 2023-04-18 13:51:02 +02:00 committed by GitHub
parent ea3c164a00
commit 25b0da0280
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 1 deletions

View File

@ -138,7 +138,7 @@ proc sendNeighbours*(d: DiscoveryProtocol, node: Node, neighbours: seq[Node]) =
block: block:
let payload = rlp.encode((nodes, expiration())) let payload = rlp.encode((nodes, expiration()))
let msg = pack(cmdNeighbours, payload, d.privKey) let msg = pack(cmdNeighbours, payload, d.privKey)
trace "Neighbours to", node, nodes trace "Neighbours to", node, nodes = $nodes
d.send(node, msg) d.send(node, msg)
nodes.setLen(0) nodes.setLen(0)

View File

@ -12,6 +12,7 @@
import import
std/[uri, strutils, net], std/[uri, strutils, net],
pkg/chronicles,
../keys ../keys
export keys export keys
@ -133,3 +134,6 @@ proc `$`*(a: Address): string =
result.add($a.ip) result.add($a.ip)
result.add(":" & $a.udpPort) result.add(":" & $a.udpPort)
result.add(":" & $a.tcpPort) result.add(":" & $a.tcpPort)
chronicles.formatIt(Address): $it
chronicles.formatIt(ENode): $it

View File

@ -95,6 +95,9 @@ proc `$`*(n: Node): string =
else: else:
"Node[" & $n.node.address.ip & ":" & $n.node.address.udpPort & "]" "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 hash*(n: Node): hashes.Hash = hash(n.node.pubkey.toRaw)
proc `==`*(a, b: Node): bool = (a.isNil and b.isNil) or 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) (not a.isNil and not b.isNil and a.node.pubkey == b.node.pubkey)