aboutsummaryrefslogtreecommitdiffstats
path: root/swarm/network/stream/delivery.go
diff options
context:
space:
mode:
authorViktor TrĂ³n <viktor.tron@gmail.com>2018-09-12 17:24:56 +0800
committerBalint Gabor <balint.g@gmail.com>2018-09-12 17:24:56 +0800
commitbfce00385f1c8dab222b7ddab6c336177a5ae731 (patch)
tree8b3d2b2ce30e8b5eaf6db5b89a6c5570c3997cff /swarm/network/stream/delivery.go
parentb06ff563a1f1095407612e04a1707e13d2dc20da (diff)
downloaddexon-bfce00385f1c8dab222b7ddab6c336177a5ae731.tar
dexon-bfce00385f1c8dab222b7ddab6c336177a5ae731.tar.gz
dexon-bfce00385f1c8dab222b7ddab6c336177a5ae731.tar.bz2
dexon-bfce00385f1c8dab222b7ddab6c336177a5ae731.tar.lz
dexon-bfce00385f1c8dab222b7ddab6c336177a5ae731.tar.xz
dexon-bfce00385f1c8dab222b7ddab6c336177a5ae731.tar.zst
dexon-bfce00385f1c8dab222b7ddab6c336177a5ae731.zip
Kademlia refactor (#17641)
* swarm/network: simplify kademlia/hive; rid interfaces * swarm, swarm/network/stream, swarm/netork/simulations,, swarm/pss: adapt to new Kad API * swarm/network: minor changes re review; add missing lock to NeighbourhoodDepthC
Diffstat (limited to 'swarm/network/stream/delivery.go')
-rw-r--r--swarm/network/stream/delivery.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/swarm/network/stream/delivery.go b/swarm/network/stream/delivery.go
index 36040339d..627352535 100644
--- a/swarm/network/stream/delivery.go
+++ b/swarm/network/stream/delivery.go
@@ -47,15 +47,15 @@ var (
type Delivery struct {
db *storage.DBAPI
- overlay network.Overlay
+ kad *network.Kademlia
receiveC chan *ChunkDeliveryMsg
getPeer func(discover.NodeID) *Peer
}
-func NewDelivery(overlay network.Overlay, db *storage.DBAPI) *Delivery {
+func NewDelivery(kad *network.Kademlia, db *storage.DBAPI) *Delivery {
d := &Delivery{
db: db,
- overlay: overlay,
+ kad: kad,
receiveC: make(chan *ChunkDeliveryMsg, deliveryCap),
}
@@ -172,7 +172,7 @@ func (d *Delivery) handleRetrieveRequestMsg(ctx context.Context, sp *Peer, req *
t := time.NewTimer(10 * time.Minute)
defer t.Stop()
- log.Debug("waiting delivery", "peer", sp.ID(), "hash", req.Addr, "node", common.Bytes2Hex(d.overlay.BaseAddr()), "created", created)
+ log.Debug("waiting delivery", "peer", sp.ID(), "hash", req.Addr, "node", common.Bytes2Hex(d.kad.BaseAddr()), "created", created)
start := time.Now()
select {
case <-chunk.ReqC:
@@ -269,8 +269,8 @@ func (d *Delivery) RequestFromPeers(ctx context.Context, hash []byte, skipCheck
var err error
requestFromPeersCount.Inc(1)
- d.overlay.EachConn(hash, 255, func(p network.OverlayConn, po int, nn bool) bool {
- spId := p.(network.Peer).ID()
+ d.kad.EachConn(hash, 255, func(p *network.Peer, po int, nn bool) bool {
+ spId := p.ID()
for _, p := range peersToSkip {
if p == spId {
log.Trace("Delivery.RequestFromPeers: skip peer", "peer", spId)