diff --git a/p2p/peerManager/peerManager.go b/p2p/peerManager/peerManager.go index 5b09f6a268..2cf90793e9 100644 --- a/p2p/peerManager/peerManager.go +++ b/p2p/peerManager/peerManager.go @@ -342,13 +342,14 @@ func (pm *BasicPeerManager) GetPeers(location common.Location, data interface{}, panic("Invalid peer quality") } - if len(peerList) == C_peerCount { + lenPeer := len(peerList) + if lenPeer >= C_peerCount { // Found sufficient number of peers return peerList } // Query the DHT for more peers - return pm.queryDHT(location, data, peerList, C_peerCount-len(peerList)) + return pm.queryDHT(location, data, peerList, C_peerCount-lenPeer) } func (pm *BasicPeerManager) queryDHT(location common.Location, data interface{}, peerList []p2p.PeerID, peerCount int) []p2p.PeerID {