Merge pull request #4785 from strahe/fix/fast-connect-bootstrappers
async connect to bootstrappers
This commit is contained in:
commit
1df7318450
@ -191,11 +191,17 @@ func (pmgr *PeerMgr) doExpand(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.Info("connecting to bootstrap peers")
|
log.Info("connecting to bootstrap peers")
|
||||||
|
wg := sync.WaitGroup{}
|
||||||
for _, bsp := range pmgr.bootstrappers {
|
for _, bsp := range pmgr.bootstrappers {
|
||||||
|
wg.Add(1)
|
||||||
|
go func(bsp peer.AddrInfo) {
|
||||||
|
defer wg.Done()
|
||||||
if err := pmgr.h.Connect(ctx, bsp); err != nil {
|
if err := pmgr.h.Connect(ctx, bsp); err != nil {
|
||||||
log.Warnf("failed to connect to bootstrap peer: %s", err)
|
log.Warnf("failed to connect to bootstrap peer: %s", err)
|
||||||
}
|
}
|
||||||
|
}(bsp)
|
||||||
}
|
}
|
||||||
|
wg.Wait()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user