mirror of https://github.com/status-im/nim-eth.git
Comments addressed
This commit is contained in:
parent
02843c0013
commit
bc23b68c95
|
@ -419,6 +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 numTries = 0
|
var numTries = 0
|
||||||
if bootstrapNodes.len != 0:
|
if bootstrapNodes.len != 0:
|
||||||
while true:
|
while true:
|
||||||
|
@ -427,12 +428,14 @@ 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)
|
||||||
|
await sleepAsync(retryInterval)
|
||||||
else:
|
else:
|
||||||
info "Failed to bond with bootstrap nodes"
|
info "Failed to bond with bootstrap nodes"
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
discard await k.lookupRandom()
|
discard await k.lookupRandom() # Prepopulate the routing table
|
||||||
else:
|
else:
|
||||||
info "Skipping discovery bootstrap, no bootnodes provided"
|
info "Skipping discovery bootstrap, no bootnodes provided"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue