mirror of https://github.com/status-im/nim-eth.git
Use chronos durations
This commit is contained in:
parent
ca8519ef61
commit
2c12746c03
|
@ -46,7 +46,7 @@ type
|
||||||
const
|
const
|
||||||
BUCKET_SIZE = 16
|
BUCKET_SIZE = 16
|
||||||
BITS_PER_HOP = 8
|
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
|
FIND_CONCURRENCY = 3 # parallel find node lookups
|
||||||
ID_SIZE = 256
|
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.} =
|
proc bootstrap*(k: KademliaProtocol, bootstrapNodes: seq[Node], retries = 0) {.async.} =
|
||||||
## Bond with bootstrap nodes and do initial lookup. Retry `retries` times
|
## Bond with bootstrap nodes and do initial lookup. Retry `retries` times
|
||||||
## in case of failure, or indefinitely if `retries` is 0.
|
## in case of failure, or indefinitely if `retries` is 0.
|
||||||
var retryInterval = 2
|
var retryInterval = chronos.milliseconds(2)
|
||||||
var numTries = 0
|
var numTries = 0
|
||||||
if bootstrapNodes.len != 0:
|
if bootstrapNodes.len != 0:
|
||||||
while true:
|
while true:
|
||||||
|
@ -428,7 +428,7 @@ proc bootstrap*(k: KademliaProtocol, bootstrapNodes: seq[Node], retries = 0) {.a
|
||||||
inc numTries
|
inc numTries
|
||||||
if retries == 0 or numTries < retries:
|
if retries == 0 or numTries < retries:
|
||||||
info "Failed to bond with bootstrap nodes, retrying"
|
info "Failed to bond with bootstrap nodes, retrying"
|
||||||
retryInterval = min(10000, retryInterval * 2)
|
retryInterval = min(chronos.seconds(10), retryInterval * 2)
|
||||||
await sleepAsync(retryInterval)
|
await sleepAsync(retryInterval)
|
||||||
else:
|
else:
|
||||||
info "Failed to bond with bootstrap nodes"
|
info "Failed to bond with bootstrap nodes"
|
||||||
|
|
Loading…
Reference in New Issue