diff options
author | Viktor TrĂ³n <viktor.tron@gmail.com> | 2018-09-27 13:08:58 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-27 13:08:58 +0800 |
commit | c3cfdfacd00bf61c3f6ffaf7714b084f62de635c (patch) | |
tree | d5e0a020cd96879438b2db2744be4c8f8112432b /swarm/storage/netstore.go | |
parent | 4b6824e07b1b7c5a2907143b4d122283eadb2474 (diff) | |
parent | 3f7acbbeb929bc3a2a3073bae15977ec69761bab (diff) | |
download | dexon-c3cfdfacd00bf61c3f6ffaf7714b084f62de635c.tar dexon-c3cfdfacd00bf61c3f6ffaf7714b084f62de635c.tar.gz dexon-c3cfdfacd00bf61c3f6ffaf7714b084f62de635c.tar.bz2 dexon-c3cfdfacd00bf61c3f6ffaf7714b084f62de635c.tar.lz dexon-c3cfdfacd00bf61c3f6ffaf7714b084f62de635c.tar.xz dexon-c3cfdfacd00bf61c3f6ffaf7714b084f62de635c.tar.zst dexon-c3cfdfacd00bf61c3f6ffaf7714b084f62de635c.zip |
Merge pull request #17757 from ethersphere/retrieve-request-ttl-pr
swarm: prevent forever running retrieve request loops
Diffstat (limited to 'swarm/storage/netstore.go')
-rw-r--r-- | swarm/storage/netstore.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/swarm/storage/netstore.go b/swarm/storage/netstore.go index a3a552232..16bc48a9a 100644 --- a/swarm/storage/netstore.go +++ b/swarm/storage/netstore.go @@ -34,7 +34,7 @@ type ( ) type NetFetcher interface { - Request(ctx context.Context) + Request(ctx context.Context, hopCount uint8) Offer(ctx context.Context, source *enode.ID) } @@ -263,6 +263,9 @@ func (f *fetcher) Fetch(rctx context.Context) (Chunk, error) { // If there is a source in the context then it is an offer, otherwise a request sourceIF := rctx.Value("source") + + hopCount, _ := rctx.Value("hopcount").(uint8) + if sourceIF != nil { var source enode.ID if err := source.UnmarshalText([]byte(sourceIF.(string))); err != nil { @@ -270,7 +273,7 @@ func (f *fetcher) Fetch(rctx context.Context) (Chunk, error) { } f.netFetcher.Offer(rctx, &source) } else { - f.netFetcher.Request(rctx) + f.netFetcher.Request(rctx, hopCount) } // wait until either the chunk is delivered or the context is done |