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/network/stream | |
parent | 4b6824e07b1b7c5a2907143b4d122283eadb2474 (diff) | |
parent | 3f7acbbeb929bc3a2a3073bae15977ec69761bab (diff) | |
download | dexon-c3cfdfacd00bf61c3f6ffaf7714b084f62de635c.tar.gz 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/network/stream')
-rw-r--r-- | swarm/network/stream/delivery.go | 6 | ||||
-rw-r--r-- | swarm/network/stream/stream.go | 2 |
2 files changed, 6 insertions, 2 deletions
diff --git a/swarm/network/stream/delivery.go b/swarm/network/stream/delivery.go index 431136ab1..c2adb1009 100644 --- a/swarm/network/stream/delivery.go +++ b/swarm/network/stream/delivery.go @@ -128,6 +128,7 @@ func (s *SwarmChunkServer) GetData(ctx context.Context, key []byte) ([]byte, err type RetrieveRequestMsg struct { Addr storage.Address SkipCheck bool + HopCount uint8 } func (d *Delivery) handleRetrieveRequestMsg(ctx context.Context, sp *Peer, req *RetrieveRequestMsg) error { @@ -148,7 +149,9 @@ func (d *Delivery) handleRetrieveRequestMsg(ctx context.Context, sp *Peer, req * var cancel func() // TODO: do something with this hardcoded timeout, maybe use TTL in the future - ctx, cancel = context.WithTimeout(context.WithValue(ctx, "peer", sp.ID().String()), network.RequestTimeout) + ctx = context.WithValue(ctx, "peer", sp.ID().String()) + ctx = context.WithValue(ctx, "hopcount", req.HopCount) + ctx, cancel = context.WithTimeout(ctx, network.RequestTimeout) go func() { select { @@ -247,6 +250,7 @@ func (d *Delivery) RequestFromPeers(ctx context.Context, req *network.Request) ( err := sp.SendPriority(ctx, &RetrieveRequestMsg{ Addr: req.Addr, SkipCheck: req.SkipCheck, + HopCount: req.HopCount, }, Top) if err != nil { return nil, nil, err diff --git a/swarm/network/stream/stream.go b/swarm/network/stream/stream.go index ea7cce8cb..65b8dff5a 100644 --- a/swarm/network/stream/stream.go +++ b/swarm/network/stream/stream.go @@ -639,7 +639,7 @@ func (c *clientParams) clientCreated() { // Spec is the spec of the streamer protocol var Spec = &protocols.Spec{ Name: "stream", - Version: 6, + Version: 7, MaxMsgSize: 10 * 1024 * 1024, Messages: []interface{}{ UnsubscribeMsg{}, |