@@ -390,46 +390,42 @@ func (k *Kademlia) EachBin(base []byte, pof pot.Pof, o int, eachBinFunc func(con
390
390
// EachConn is an iterator with args (base, po, f) applies f to each live peer
391
391
// that has proximity order po or less as measured from the base
392
392
// 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 ) {
395
394
k .lock .RLock ()
396
395
defer k .lock .RUnlock ()
397
396
k .eachConn (base , o , f )
398
397
}
399
398
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 ) {
401
400
if len (base ) == 0 {
402
401
base = k .base
403
402
}
404
- depth := depthForPot (k .conns , k .MinProxBinSize , k .base )
405
403
k .conns .EachNeighbour (base , Pof , func (val pot.Val , po int ) bool {
406
404
if po > o {
407
405
return true
408
406
}
409
- return f (val .(* Peer ), po , po >= depth )
407
+ return f (val .(* Peer ), po )
410
408
})
411
409
}
412
410
413
411
// EachAddr called with (base, po, f) is an iterator applying f to each known peer
414
412
// that has proximity order o or less as measured from the base
415
413
// 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 ) {
418
415
k .lock .RLock ()
419
416
defer k .lock .RUnlock ()
420
417
k .eachAddr (base , o , f )
421
418
}
422
419
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 ) {
424
421
if len (base ) == 0 {
425
422
base = k .base
426
423
}
427
- depth := depthForPot (k .conns , k .MinProxBinSize , k .base )
428
424
k .addrs .EachNeighbour (base , Pof , func (val pot.Val , po int ) bool {
429
425
if po > o {
430
426
return true
431
427
}
432
- return f (val .(* entry ).BzzAddr , po , po >= depth )
428
+ return f (val .(* entry ).BzzAddr , po )
433
429
})
434
430
}
435
431
@@ -687,12 +683,11 @@ func (k *Kademlia) saturation() int {
687
683
// TODO move to separate testing tools file
688
684
func (k * Kademlia ) knowNeighbours (addrs [][]byte ) (got bool , n int , missing [][]byte ) {
689
685
pm := make (map [string ]bool )
690
-
686
+ depth := depthForPot ( k . conns , k . MinProxBinSize , k . base )
691
687
// 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)
696
691
if po < depth {
697
692
return false
698
693
}
@@ -724,12 +719,8 @@ func (k *Kademlia) knowNeighbours(addrs [][]byte) (got bool, n int, missing [][]
724
719
// It is used in Healthy function for testing only
725
720
func (k * Kademlia ) connectedNeighbours (peers [][]byte ) (got bool , n int , missing [][]byte ) {
726
721
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)
731
722
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 {
733
724
if po < depth {
734
725
return false
735
726
}
0 commit comments