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:
Olaoluwa Osuntokun 2018-01-28 14:50:15 -08:00
parent a94648e9dc
commit 47dc2d3b70
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

@ -729,13 +729,13 @@ func (s *server) peerBootstrapper(numTargetPeers uint32,
// With the number of peers we need calculated, we'll
// query the network bootstrappers to sample a set of
// random addrs for us.
s.mu.Lock()
s.mu.RLock()
ignoreList := make(map[autopilot.NodeID]struct{})
for _, peer := range s.peersByPub {
nID := autopilot.NewNodeID(peer.addr.IdentityKey)
ignoreList[nID] = struct{}{}
}
s.mu.Unlock()
s.mu.RUnlock()
peerAddrs, err := discovery.MultiSourceBootstrap(
ignoreList, numNeeded*2, bootStrappers...,