From f546733f9e9d2ca49a621a5bed16e7af1951e85d Mon Sep 17 00:00:00 2001 From: wizeguyy Date: Wed, 15 May 2024 10:51:29 -0500 Subject: [PATCH] bugfix: always at least allocate empty peer map --- p2p/node/peerManager/peerManager.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/p2p/node/peerManager/peerManager.go b/p2p/node/peerManager/peerManager.go index a0d547dbc8..be7b443a1d 100644 --- a/p2p/node/peerManager/peerManager.go +++ b/p2p/node/peerManager/peerManager.go @@ -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, } @@ -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()