@@ -390,46 +390,42 @@ func (k *Kademlia) EachBin(base []byte, pof pot.Pof, o int, eachBinFunc func(con
390390// EachConn is an iterator with args (base, po, f) applies f to each live peer
391391// that has proximity order po or less as measured from the base
392392// if base is nil, kademlia base address is used
393- // It returns peers in order deepest to shallowest
394- func (k * Kademlia ) EachConn (base []byte , o int , f func (* Peer , int , bool ) bool ) {
393+ func (k * Kademlia ) EachConn (base []byte , o int , f func (* Peer , int ) bool ) {
395394 k .lock .RLock ()
396395 defer k .lock .RUnlock ()
397396 k .eachConn (base , o , f )
398397}
399398
400- func (k * Kademlia ) eachConn (base []byte , o int , f func (* Peer , int , bool ) bool ) {
399+ func (k * Kademlia ) eachConn (base []byte , o int , f func (* Peer , int ) bool ) {
401400 if len (base ) == 0 {
402401 base = k .base
403402 }
404- depth := depthForPot (k .conns , k .MinProxBinSize , k .base )
405403 k .conns .EachNeighbour (base , Pof , func (val pot.Val , po int ) bool {
406404 if po > o {
407405 return true
408406 }
409- return f (val .(* Peer ), po , po >= depth )
407+ return f (val .(* Peer ), po )
410408 })
411409}
412410
413411// EachAddr called with (base, po, f) is an iterator applying f to each known peer
414412// that has proximity order o or less as measured from the base
415413// if base is nil, kademlia base address is used
416- // It returns peers in order deepest to shallowest
417- func (k * Kademlia ) EachAddr (base []byte , o int , f func (* BzzAddr , int , bool ) bool ) {
414+ func (k * Kademlia ) EachAddr (base []byte , o int , f func (* BzzAddr , int ) bool ) {
418415 k .lock .RLock ()
419416 defer k .lock .RUnlock ()
420417 k .eachAddr (base , o , f )
421418}
422419
423- func (k * Kademlia ) eachAddr (base []byte , o int , f func (* BzzAddr , int , bool ) bool ) {
420+ func (k * Kademlia ) eachAddr (base []byte , o int , f func (* BzzAddr , int ) bool ) {
424421 if len (base ) == 0 {
425422 base = k .base
426423 }
427- depth := depthForPot (k .conns , k .MinProxBinSize , k .base )
428424 k .addrs .EachNeighbour (base , Pof , func (val pot.Val , po int ) bool {
429425 if po > o {
430426 return true
431427 }
432- return f (val .(* entry ).BzzAddr , po , po >= depth )
428+ return f (val .(* entry ).BzzAddr , po )
433429 })
434430}
435431
@@ -687,12 +683,11 @@ func (k *Kademlia) saturation() int {
687683// TODO move to separate testing tools file
688684func (k * Kademlia ) knowNeighbours (addrs [][]byte ) (got bool , n int , missing [][]byte ) {
689685 pm := make (map [string ]bool )
690-
686+ depth := depthForPot ( k . conns , k . MinProxBinSize , k . base )
691687 // create a map with all peers at depth and deeper known in the kademlia
692- // in order deepest to shallowest compared to the kademlia base address
693- // all bins (except self) are included (0 <= bin <= 255)
694- depth := depthForPot (k .addrs , k .MinProxBinSize , k .base )
695- k .eachAddr (nil , 255 , func (p * BzzAddr , po int , nn bool ) bool {
688+ k .eachAddr (nil , 255 , func (p * BzzAddr , po int ) bool {
689+ // in order deepest to shallowest compared to the kademlia base address
690+ // all bins (except self) are included (0 <= bin <= 255)
696691 if po < depth {
697692 return false
698693 }
@@ -724,12 +719,8 @@ func (k *Kademlia) knowNeighbours(addrs [][]byte) (got bool, n int, missing [][]
724719// It is used in Healthy function for testing only
725720func (k * Kademlia ) connectedNeighbours (peers [][]byte ) (got bool , n int , missing [][]byte ) {
726721 pm := make (map [string ]bool )
727-
728- // create a map with all peers at depth and deeper that are connected in the kademlia
729- // in order deepest to shallowest compared to the kademlia base address
730- // all bins (except self) are included (0 <= bin <= 255)
731722 depth := depthForPot (k .conns , k .MinProxBinSize , k .base )
732- k .eachConn (nil , 255 , func (p * Peer , po int , nn bool ) bool {
723+ k .eachConn (nil , 255 , func (p * Peer , po int ) bool {
733724 if po < depth {
734725 return false
735726 }
0 commit comments