diff --git a/eth/p2p/discoveryv5/protocol.nim b/eth/p2p/discoveryv5/protocol.nim index 0afc7f0..6c1f3b0 100644 --- a/eth/p2p/discoveryv5/protocol.nim +++ b/eth/p2p/discoveryv5/protocol.nim @@ -379,6 +379,18 @@ proc waitNodes(d: Protocol, fromNode: Node, reqId: RequestId): discovery_message_requests_outgoing.inc(labelValues = ["no_response"]) return err("Nodes message not received in time") +proc sendMessage*[T: SomeMessage](d: Protocol, toId: NodeId, toAddr: Address, m: T): + RequestId = + let + reqId = RequestId.init(d.rng[]) + message = encodeMessage(m, reqId) + + trace "Send message packet", dstId = toId, toAddr, kind = messageKind(T) + discovery_message_requests_outgoing.inc() + + d.transport.sendMessage(toId, toAddr, message) + return reqId + proc sendMessage*[T: SomeMessage](d: Protocol, toNode: Node, m: T): RequestId = doAssert(toNode.address.isSome())