Merge pull request #4785 from strahe/fix/fast-connect-bootstrappers

async connect to bootstrappers
This commit is contained in:
Łukasz Magiera 2020-11-10 17:45:06 +01:00 committed by GitHub
commit 1df7318450
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
}