Skip to content

Commit

Permalink
Merge pull request #4785 from strahe/fix/fast-connect-bootstrappers
Browse files Browse the repository at this point in the history
async connect to bootstrappers
  • Loading branch information
magik6k authored Nov 10, 2020
2 parents 3ec25cb + e340996 commit 1df7318
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/peermgr/peermgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,17 @@ func (pmgr *PeerMgr) doExpand(ctx context.Context) {
}

log.Info("connecting to bootstrap peers")
wg := sync.WaitGroup{}
for _, bsp := range pmgr.bootstrappers {
if err := pmgr.h.Connect(ctx, bsp); err != nil {
log.Warnf("failed to connect to bootstrap peer: %s", err)
}
wg.Add(1)
go func(bsp peer.AddrInfo) {
defer wg.Done()
if err := pmgr.h.Connect(ctx, bsp); err != nil {
log.Warnf("failed to connect to bootstrap peer: %s", err)
}
}(bsp)
}
wg.Wait()
return
}

Expand Down

0 comments on commit 1df7318

Please sign in to comment.