mirror of
https://github.com/codex-storage/nim-codex-dht.git
synced 2025-01-09 19:35:45 +00:00
dht: waitMessage: expose timeout as parameter, keeping default
defults to ResponseTimeout as before Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
parent
6e61e02091
commit
316464fc71
@ -480,12 +480,12 @@ proc waitResponse*[T: SomeMessage](d: Protocol, node: Node, msg: T):
|
||||
result = d.waitMessage(node, reqId)
|
||||
sendRequest(d, node, msg, reqId)
|
||||
|
||||
proc waitMessage(d: Protocol, fromNode: Node, reqId: RequestId):
|
||||
proc waitMessage(d: Protocol, fromNode: Node, reqId: RequestId, timeout = ResponseTimeout):
|
||||
Future[Option[Message]] =
|
||||
result = newFuture[Option[Message]]("waitMessage")
|
||||
let res = result
|
||||
let key = (fromNode.id, reqId)
|
||||
sleepAsync(ResponseTimeout).addCallback() do(data: pointer):
|
||||
sleepAsync(timeout).addCallback() do(data: pointer):
|
||||
d.awaitedMessages.del(key)
|
||||
if not res.finished:
|
||||
res.complete(none(Message))
|
||||
|
Loading…
x
Reference in New Issue
Block a user