mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
swarm/network: early depth check
This commit is contained in:
parent
d0ca8b1c3a
commit
b7c7d95f4f
1 changed files with 5 additions and 4 deletions
|
|
@ -710,6 +710,11 @@ func (k *Kademlia) saturation() int {
|
||||||
func (k *Kademlia) isSaturated(peersPerBin []int, depth int) bool {
|
func (k *Kademlia) isSaturated(peersPerBin []int, depth int) bool {
|
||||||
// depth could be calculated from k but as this is called from `GetHealthInfo()`,
|
// depth could be calculated from k but as this is called from `GetHealthInfo()`,
|
||||||
// the depth has already been calculated so we can require it as a parameter
|
// the depth has already been calculated so we can require it as a parameter
|
||||||
|
|
||||||
|
// early check for depth
|
||||||
|
if depth != len(peersPerBin) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
unsaturatedBins := make([]int, 0)
|
unsaturatedBins := make([]int, 0)
|
||||||
k.conns.EachBin(k.base, Pof, 0, func(po, size int, f func(func(val pot.Val) bool) bool) bool {
|
k.conns.EachBin(k.base, Pof, 0, func(po, size int, f func(func(val pot.Val) bool) bool) bool {
|
||||||
|
|
||||||
|
|
@ -726,10 +731,6 @@ func (k *Kademlia) isSaturated(peersPerBin []int, depth int) bool {
|
||||||
})
|
})
|
||||||
|
|
||||||
log.Trace("list of unsaturated bins", "unsaturatedBins", unsaturatedBins)
|
log.Trace("list of unsaturated bins", "unsaturatedBins", unsaturatedBins)
|
||||||
// early check for depth
|
|
||||||
if depth != len(peersPerBin) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return len(unsaturatedBins) == 0
|
return len(unsaturatedBins) == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue