Skip to content

Commit

Permalink
bugfix: always at least allocate empty peer map
Browse files Browse the repository at this point in the history
  • Loading branch information
wizeguyy committed May 15, 2024
1 parent e3cfc37 commit f546733
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions p2p/node/peerManager/peerManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func (pm *BasicPeerManager) GetSelfID() p2p.PeerID {
}

func (pm *BasicPeerManager) getPeersHelper(peerDB *peerdb.PeerDB, numPeers int) map[p2p.PeerID]struct{} {
peerSubset := make(map[p2p.PeerID]struct{})
peerSubset := make(map[p2p.PeerID]struct{}, C_peerCount)
q := query.Query{
Limit: numPeers,
}
Expand Down Expand Up @@ -364,7 +364,7 @@ func (pm *BasicPeerManager) getBestPeersWithFallback(location common.Location) m
locName := location.Name()
if pm.peerDBs[locName] == nil {
// There have not been any peers added to this topic
return nil
return make(map[peer.ID]struct{}, C_peerCount)
}

bestPeersCount := pm.peerDBs[locName][Best].GetPeerCount()
Expand Down

0 comments on commit f546733

Please sign in to comment.