@@ -128,15 +128,15 @@ func (r *routes) lookupOrCalculate(name PeerName, broadcast *broadcastRoutes, es
128
128
return <- res
129
129
}
130
130
131
- // RandomNeighbours chooses min(log2(n_peers), n_neighbouring_peers)
131
+ // RandomNeighbours chooses min(2 log2(n_peers), n_neighbouring_peers)
132
132
// neighbours, with a random distribution that is topology-sensitive,
133
133
// favouring neighbours at the end of "bottleneck links". We determine the
134
134
// latter based on the unicast routing table. If a neighbour appears as the
135
135
// value more frequently than others - meaning that we reach a higher
136
136
// proportion of peers via that neighbour than other neighbours - then it is
137
137
// chosen with a higher probability.
138
138
//
139
- // Note that we choose log2 (n_peers) *neighbours*, not peers. Consequently, on
139
+ // Note that we choose 2log2 (n_peers) *neighbours*, not peers. Consequently, on
140
140
// sparsely connected peers this function returns a higher proportion of
141
141
// neighbours than elsewhere. In extremis, on peers with fewer than
142
142
// log2(n_peers) neighbours, all neighbours are returned.
@@ -152,7 +152,7 @@ func (r *routes) randomNeighbours(except PeerName) []PeerName {
152
152
weights [dst ]++
153
153
}
154
154
}
155
- needed := int (math .Min (math .Log2 (float64 (len (r .unicastAll ))), float64 (len (weights ))))
155
+ needed := int (math .Min (2 * math .Log2 (float64 (len (r .unicastAll ))), float64 (len (weights ))))
156
156
destinations := make ([]PeerName , 0 , needed )
157
157
for len (destinations ) < needed {
158
158
// Pick a random point on the distribution and linear search for it
0 commit comments