diff --git a/eth/p2p/discoveryv5/protocol.nim b/eth/p2p/discoveryv5/protocol.nim index 0c3942d..5d886c2 100644 --- a/eth/p2p/discoveryv5/protocol.nim +++ b/eth/p2p/discoveryv5/protocol.nim @@ -91,6 +91,7 @@ import export options, results, node, enr, encoding.maxDiscv5PacketSize +declareCounter discv5_network_bytes, "discv5 traffic", labels = ["direction"] declareCounter discovery_message_requests_outgoing, "Discovery protocol outgoing message requests", labels = ["response"] declareCounter discovery_message_requests_incoming, @@ -276,6 +277,8 @@ proc sendTo(d: Protocol, a: Address, data: seq[byte]): Future[void] {.async.} = # because of ping failures due to own network connection failure. warn "Discovery send failed", msg = e.msg, address = $ta + discv5_network_bytes.inc(data.len, labelValues = ["out"]) + proc send*(d: Protocol, a: Address, data: seq[byte]) = asyncSpawn sendTo(d, a, data) @@ -422,6 +425,8 @@ proc sendWhoareyou(d: Protocol, toId: NodeId, a: Address, debug "Node with this id already has ongoing handshake, ignoring packet" proc receive*(d: Protocol, a: Address, packet: openArray[byte]) = + discv5_network_bytes.inc(packet.len, labelValues = ["in"]) + let decoded = d.codec.decodePacket(a, packet) if decoded.isOk: let packet = decoded[]