server: grab the read-mutex within the main loop of the peerBootstrapper
A recent commit modified the mutex in the server to the read/write. In order to further reduce contention, we’ll grab the read lock when we’re examining get set of peers to ignore.
This commit is contained in:
parent
a94648e9dc
commit
47dc2d3b70
@ -729,13 +729,13 @@ func (s *server) peerBootstrapper(numTargetPeers uint32,
|
|||||||
// With the number of peers we need calculated, we'll
|
// With the number of peers we need calculated, we'll
|
||||||
// query the network bootstrappers to sample a set of
|
// query the network bootstrappers to sample a set of
|
||||||
// random addrs for us.
|
// random addrs for us.
|
||||||
s.mu.Lock()
|
s.mu.RLock()
|
||||||
ignoreList := make(map[autopilot.NodeID]struct{})
|
ignoreList := make(map[autopilot.NodeID]struct{})
|
||||||
for _, peer := range s.peersByPub {
|
for _, peer := range s.peersByPub {
|
||||||
nID := autopilot.NewNodeID(peer.addr.IdentityKey)
|
nID := autopilot.NewNodeID(peer.addr.IdentityKey)
|
||||||
ignoreList[nID] = struct{}{}
|
ignoreList[nID] = struct{}{}
|
||||||
}
|
}
|
||||||
s.mu.Unlock()
|
s.mu.RUnlock()
|
||||||
|
|
||||||
peerAddrs, err := discovery.MultiSourceBootstrap(
|
peerAddrs, err := discovery.MultiSourceBootstrap(
|
||||||
ignoreList, numNeeded*2, bootStrappers...,
|
ignoreList, numNeeded*2, bootStrappers...,
|
||||||
|
Loading…
Reference in New Issue
Block a user