attempt to clean up send proc names

- interface between Transport and Protocol is at the encoded Message
level
This commit is contained in:
Csaba Kiraly 2022-02-16 18:50:41 +01:00
parent b03d5eb3c7
commit 8298acd410
2 changed files with 8 additions and 8 deletions

View File

@ -230,7 +230,7 @@ proc sendNodes(d: Protocol, toId: NodeId, toAddr: Address, reqId: RequestId,
message: NodesMessage, reqId: RequestId) {.nimcall.} =
trace "Respond message packet", dstId = toId, address = toAddr,
kind = MessageKind.nodes
d.transport.send(toId, toAddr, encodeMessage(message, reqId))
d.transport.sendMessage(toId, toAddr, encodeMessage(message, reqId))
if nodes.len == 0:
# In case of 0 nodes, a reply is still needed
@ -258,7 +258,7 @@ proc handlePing(d: Protocol, fromId: NodeId, fromAddr: Address,
port: fromAddr.port.uint16)
trace "Respond message packet", dstId = fromId, address = fromAddr,
kind = MessageKind.pong
d.transport.send(fromId, fromAddr, encodeMessage(pong, reqId))
d.transport.sendMessage(fromId, fromAddr, encodeMessage(pong, reqId))
proc handleFindNode(d: Protocol, fromId: NodeId, fromAddr: Address,
fn: FindNodeMessage, reqId: RequestId) =
@ -294,7 +294,7 @@ proc handleTalkReq(d: Protocol, fromId: NodeId, fromAddr: Address,
trace "Respond message packet", dstId = fromId, address = fromAddr,
kind = MessageKind.talkresp
d.transport.send(fromId, fromAddr, encodeMessage(talkresp, reqId))
d.transport.sendMessage(fromId, fromAddr, encodeMessage(talkresp, reqId))
proc handleMessage(d: Protocol, srcId: NodeId, fromAddr: Address,
message: Message) =

View File

@ -31,7 +31,7 @@ type
node: Node
message: seq[byte]
proc send*(t: Transport, a: Address, data: seq[byte]) =
proc sendToA(t: Transport, a: Address, data: seq[byte]) =
let ta = initTAddress(a.ip, a.port)
let f = t.transp.sendTo(ta, data)
f.callback = proc(data: pointer) {.gcsafe.} =
@ -50,12 +50,12 @@ proc send*(t: Transport, a: Address, data: seq[byte]) =
proc send(t: Transport, n: Node, data: seq[byte]) =
doAssert(n.address.isSome())
t.send(n.address.get(), data)
t.sendToA(n.address.get(), data)
proc send*(t: Transport, toId: NodeId, toAddr: Address, message: seq[byte]) =
proc sendMessage*(t: Transport, toId: NodeId, toAddr: Address, message: seq[byte]) =
let (data, _) = encodeMessagePacket(t.rng[], t.codec, toId, toAddr,
message)
t.send(toAddr, data)
t.sendToA(toAddr, data)
# TODO: This could be improved to do the clean-up immediatily in case a non
# whoareyou response does arrive, but we would need to store the AuthTag
@ -93,7 +93,7 @@ proc sendWhoareyou(t: Transport, toId: NodeId, a: Address,
t.codec.handshakes.del(key)
trace "Send whoareyou", dstId = toId, address = a
t.send(a, data)
t.sendToA(a, data)
else:
debug "Node with this id already has ongoing handshake, ignoring packet"