diff options
author | holisticode <holistic.computing@gmail.com> | 2019-01-11 22:08:09 +0800 |
---|---|---|
committer | Viktor TrĂ³n <viktor.tron@gmail.com> | 2019-01-11 22:08:09 +0800 |
commit | 88168ff5c57b1a9c944d02e93e6e49368ccc968f (patch) | |
tree | 150f46d66bccf780044469af65ee3c70d395a320 /swarm/network/kademlia.go | |
parent | d5cad488be0069d768b358b2267cd5432b0f9a43 (diff) | |
download | dexon-88168ff5c57b1a9c944d02e93e6e49368ccc968f.tar dexon-88168ff5c57b1a9c944d02e93e6e49368ccc968f.tar.gz dexon-88168ff5c57b1a9c944d02e93e6e49368ccc968f.tar.bz2 dexon-88168ff5c57b1a9c944d02e93e6e49368ccc968f.tar.lz dexon-88168ff5c57b1a9c944d02e93e6e49368ccc968f.tar.xz dexon-88168ff5c57b1a9c944d02e93e6e49368ccc968f.tar.zst dexon-88168ff5c57b1a9c944d02e93e6e49368ccc968f.zip |
Stream subscriptions (#18355)
* swarm/network: eachBin now starts at kaddepth for nn
* swarm/network: fix Kademlia.EachBin
* swarm/network: fix kademlia.EachBin
* swarm/network: correct EachBin implementation according to requirements
* swarm/network: less addresses simplified tests
* swarm: calc kad depth outside loop in EachBin test
* swarm/network: removed printResults
* swarm/network: cleanup imports
* swarm/network: remove kademlia.EachBin; fix RequestSubscriptions and add unit test
* swarm/network/stream: address PR comments
* swarm/network/stream: package-wide subscriptionFunc
* swarm/network/stream: refactor to kad.EachConn
Diffstat (limited to 'swarm/network/kademlia.go')
-rw-r--r-- | swarm/network/kademlia.go | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/swarm/network/kademlia.go b/swarm/network/kademlia.go index 341ed20b2..ec53f70a3 100644 --- a/swarm/network/kademlia.go +++ b/swarm/network/kademlia.go @@ -356,37 +356,6 @@ func (k *Kademlia) Off(p *Peer) { } } -// EachBin is a two level nested iterator -// The outer iterator returns all bins that have known peers, in order from shallowest to deepest -// The inner iterator returns all peers per bin returned by the outer iterator, in no defined order -// TODO the po returned by the inner iterator is not reliable. However, it is not being used in this method -func (k *Kademlia) EachBin(base []byte, pof pot.Pof, o int, eachBinFunc func(conn *Peer, po int) bool) { - k.lock.RLock() - defer k.lock.RUnlock() - - var startPo int - var endPo int - kadDepth := depthForPot(k.conns, k.NeighbourhoodSize, k.base) - - k.conns.EachBin(base, Pof, o, func(po, size int, f func(func(val pot.Val, i int) bool) bool) bool { - if startPo > 0 && endPo != k.MaxProxDisplay { - startPo = endPo + 1 - } - if po < kadDepth { - endPo = po - } else { - endPo = k.MaxProxDisplay - } - - for bin := startPo; bin <= endPo; bin++ { - f(func(val pot.Val, _ int) bool { - return eachBinFunc(val.(*Peer), bin) - }) - } - return true - }) -} - // EachConn is an iterator with args (base, po, f) applies f to each live peer // that has proximity order po or less as measured from the base // if base is nil, kademlia base address is used |