mirror of https://github.com/status-im/nim-eth.git
Fixed discovery busyloop when no bootnodes provided
This commit is contained in:
parent
b84c228364
commit
02843c0013
|
@ -420,18 +420,21 @@ proc bootstrap*(k: KademliaProtocol, bootstrapNodes: seq[Node], retries = 0) {.a
|
||||||
## 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 numTries = 0
|
var numTries = 0
|
||||||
while true:
|
if bootstrapNodes.len != 0:
|
||||||
let bonded = await all(bootstrapNodes.mapIt(k.bond(it)))
|
while true:
|
||||||
if true notin bonded:
|
let bonded = await all(bootstrapNodes.mapIt(k.bond(it)))
|
||||||
info "Failed to bond with bootstrap nodes"
|
if true notin bonded:
|
||||||
inc numTries
|
inc numTries
|
||||||
if retries == 0 or numTries < retries:
|
if retries == 0 or numTries < retries:
|
||||||
info "Retrying"
|
info "Failed to bond with bootstrap nodes, retrying"
|
||||||
|
else:
|
||||||
|
info "Failed to bond with bootstrap nodes"
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
return
|
break
|
||||||
else:
|
discard await k.lookupRandom()
|
||||||
break
|
else:
|
||||||
discard await k.lookupRandom()
|
info "Skipping discovery bootstrap, no bootnodes provided"
|
||||||
|
|
||||||
proc recvPong*(k: KademliaProtocol, n: Node, token: seq[byte]) =
|
proc recvPong*(k: KademliaProtocol, n: Node, token: seq[byte]) =
|
||||||
trace "<<< pong from ", n
|
trace "<<< pong from ", n
|
||||||
|
|
Loading…
Reference in New Issue