Commit b7796c6d authored by acud's avatar acud Committed by GitHub

dont retry retrieval when main context expires (#1008)

parent 45a7c8e0
...@@ -92,8 +92,17 @@ func (s *Service) RetrieveChunk(ctx context.Context, addr swarm.Address) (swarm. ...@@ -92,8 +92,17 @@ func (s *Service) RetrieveChunk(ctx context.Context, addr swarm.Address) (swarm.
defer span.Finish() defer span.Finish()
var skipPeers []swarm.Address var skipPeers []swarm.Address
LOOP:
for i := 0; i < maxPeers; i++ { for i := 0; i < maxPeers; i++ {
select {
case <-ctx.Done():
break LOOP
default:
}
var peer swarm.Address var peer swarm.Address
chunk, peer, err := s.retrieveChunk(ctx, addr, skipPeers) chunk, peer, err := s.retrieveChunk(ctx, addr, skipPeers)
if err != nil { if err != nil {
if peer.IsZero() { if peer.IsZero() {
...@@ -289,6 +298,8 @@ func (s *Service) handler(ctx context.Context, p p2p.Peer, stream p2p.Stream) (e ...@@ -289,6 +298,8 @@ func (s *Service) handler(ctx context.Context, p p2p.Peer, stream p2p.Stream) (e
return fmt.Errorf("write delivery: %w", err) return fmt.Errorf("write delivery: %w", err)
} }
s.logger.Tracef("retrieval protocol debiting peer %s", p.Address.String())
// compute the price we charge for this chunk and debit it from p's balance // compute the price we charge for this chunk and debit it from p's balance
chunkPrice := s.pricer.Price(chunk.Address()) chunkPrice := s.pricer.Price(chunk.Address())
err = s.accounting.Debit(p.Address, chunkPrice) err = s.accounting.Debit(p.Address, chunkPrice)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment