Commit c8f0faad authored by acud's avatar acud Committed by GitHub

kademlia: add bootnode connection timeout (#1407)

parent bc750ff0
...@@ -245,6 +245,9 @@ func (k *Kad) connectBootnodes(ctx context.Context) { ...@@ -245,6 +245,9 @@ func (k *Kad) connectBootnodes(ctx context.Context) {
var attempts, connected int var attempts, connected int
var totalAttempts = maxBootnodeAttempts * len(k.bootnodes) var totalAttempts = maxBootnodeAttempts * len(k.bootnodes)
ctx, cancel := context.WithTimeout(ctx, 15*time.Second)
defer cancel()
for _, addr := range k.bootnodes { for _, addr := range k.bootnodes {
if attempts >= totalAttempts || connected >= 3 { if attempts >= totalAttempts || connected >= 3 {
return return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment