diff --git a/swarm/network/kademlia.go b/swarm/network/kademlia.go index 4ea045819e..f9b38fc48d 100644 --- a/swarm/network/kademlia.go +++ b/swarm/network/kademlia.go @@ -173,8 +173,9 @@ func (k *Kademlia) SuggestPeer() (suggestedPeer *BzzAddr, saturationDepth int, c k.lock.Lock() defer k.lock.Unlock() radius := neighbourhoodRadiusForPot(k.conns, k.NeighbourhoodSize, k.base) - // first collect undersaturated bins starting from smallest size from shallow to deep - // saturation is a map: bin size (int) -> deepening list of PO bins with that size ([]int) + // collect undersaturated bins in ascending order of number of connected peers + // and from shallow to deep (ascending order of PO) + // insert them in a map of bin arrays, keyed with the number of connected peers saturation := make(map[int][]int) var lastPO int // the last non-empty PO bin in the iteration saturationDepth = -1 // the deepest PO such that all shallower bins have >= k.MinBinSize peers diff --git a/swarm/network/simulations/discovery/discovery_test.go b/swarm/network/simulations/discovery/discovery_test.go index 0abb214db8..e695bc4ac0 100644 --- a/swarm/network/simulations/discovery/discovery_test.go +++ b/swarm/network/simulations/discovery/discovery_test.go @@ -82,7 +82,7 @@ func getDbStore(nodeID string) (*state.DBStore, error) { } var ( - nodeCount = flag.Int("nodes", 10, "number of nodes to create (default 10)") + nodeCount = flag.Int("nodes", 32, "number of nodes to create (default 32)") initCount = flag.Int("conns", 1, "number of originally connected peers (default 1)") loglevel = flag.Int("loglevel", 3, "verbosity of logs") rawlog = flag.Bool("rawlog", false, "remove terminal formatting from logs")