mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
Asynchronous Dials To Peers (#5021)
* make dial non-blocking * add sleep Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
parent
acb15a1f04
commit
069f2c5fb6
@ -161,6 +161,7 @@ func TestStaticPeering_PeersAreAdded(t *testing.T) {
|
||||
s.Start()
|
||||
s.dv5Listener = &mockListener{}
|
||||
defer s.Stop()
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
|
||||
peers := s.host.Network().Peers()
|
||||
if len(peers) != 5 {
|
||||
|
@ -311,19 +311,19 @@ func (s *Service) connectWithAllPeers(multiAddrs []ma.Multiaddr) {
|
||||
return
|
||||
}
|
||||
for _, info := range addrInfos {
|
||||
// make each dial non-blocking
|
||||
go func(info peer.AddrInfo) {
|
||||
if info.ID == s.host.ID() {
|
||||
continue
|
||||
}
|
||||
if _, ok := s.exclusionList.Get(info.ID.String()); ok {
|
||||
continue
|
||||
return
|
||||
}
|
||||
if s.Peers().IsBad(info.ID) {
|
||||
continue
|
||||
return
|
||||
}
|
||||
if err := s.host.Connect(s.ctx, info); err != nil {
|
||||
log.Errorf("Could not connect with peer %s: %v", info.String(), err)
|
||||
s.exclusionList.Set(info.ID.String(), true, 1)
|
||||
s.Peers().IncrementBadResponses(info.ID)
|
||||
}
|
||||
}(info)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user