mirror of
https://github.com/logos-storage/logos-storage-nim-dht.git
synced 2026-06-06 00:59:25 +00:00
generalize p2p delay
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
parent
43d71d4957
commit
dcb6c244c8
@ -45,10 +45,13 @@ when(true): #enable network emulator
|
||||
# call the callback on remote
|
||||
asyncCheck transp.callback(transp, remote)
|
||||
|
||||
proc getLatency(src: TransportAddress, dst: TransportAddress) : Duration =
|
||||
50.milliseconds
|
||||
|
||||
proc sendTo*[T](transp: DatagramTransport, remote: TransportAddress,
|
||||
msg: sink seq[T], msglen = -1) {.async.} =
|
||||
#echo "sending to ", remote
|
||||
await sleepAsync(50.milliseconds)
|
||||
await sleepAsync(getLatency(transp.local, remote))
|
||||
{.gcsafe.}:
|
||||
network[remote.port].recvFrom(transp.local, msg)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user