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:
Csaba Kiraly 2023-05-17 08:08:12 +02:00
parent 6e61e02091
commit 316464fc71
No known key found for this signature in database
GPG Key ID: 0FE274EE8C95166E

View File

@ -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))