Use chronos durations

This commit is contained in:
Yuriy Glukhov 2019-04-10 20:03:58 +03:00
parent ca8519ef61
commit 2c12746c03
No known key found for this signature in database
GPG Key ID: 733560674BB43E6C
1 changed files with 3 additions and 3 deletions

View File

@ -46,7 +46,7 @@ type
const
BUCKET_SIZE = 16
BITS_PER_HOP = 8
REQUEST_TIMEOUT = 900 # timeout of message round trips
REQUEST_TIMEOUT = chronos.milliseconds(900) # timeout of message round trips
FIND_CONCURRENCY = 3 # parallel find node lookups
ID_SIZE = 256
@ -419,7 +419,7 @@ proc resolve*(k: KademliaProtocol, id: NodeId): Future[Node] {.async.} =
proc bootstrap*(k: KademliaProtocol, bootstrapNodes: seq[Node], retries = 0) {.async.} =
## Bond with bootstrap nodes and do initial lookup. Retry `retries` times
## in case of failure, or indefinitely if `retries` is 0.
var retryInterval = 2
var retryInterval = chronos.milliseconds(2)
var numTries = 0
if bootstrapNodes.len != 0:
while true:
@ -428,7 +428,7 @@ proc bootstrap*(k: KademliaProtocol, bootstrapNodes: seq[Node], retries = 0) {.a
inc numTries
if retries == 0 or numTries < retries:
info "Failed to bond with bootstrap nodes, retrying"
retryInterval = min(10000, retryInterval * 2)
retryInterval = min(chronos.seconds(10), retryInterval * 2)
await sleepAsync(retryInterval)
else:
info "Failed to bond with bootstrap nodes"