protocol.sendMessage: allow destination as (NodeId, Address)

This commit is contained in:
Csaba Kiraly 2022-02-23 20:56:19 +01:00
parent a7d8082fc7
commit d4af5b8a44
1 changed files with 12 additions and 0 deletions

View File

@ -379,6 +379,18 @@ proc waitNodes(d: Protocol, fromNode: Node, reqId: RequestId):
discovery_message_requests_outgoing.inc(labelValues = ["no_response"]) discovery_message_requests_outgoing.inc(labelValues = ["no_response"])
return err("Nodes message not received in time") 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): proc sendMessage*[T: SomeMessage](d: Protocol, toNode: Node, m: T):
RequestId = RequestId =
doAssert(toNode.address.isSome()) doAssert(toNode.address.isSome())