Skip to content

Commit

Permalink
fix: ctx
Browse files Browse the repository at this point in the history
  • Loading branch information
istae committed Oct 24, 2023
1 parent 95884b5 commit 0d0c464
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/retrieval/retrieval.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,8 @@ func (s *Service) closestPeer(addr swarm.Address, skipPeers []swarm.Address, all
return closest, nil
}

func (s *Service) handler(ctx context.Context, p p2p.Peer, stream p2p.Stream) (err error) {
ctx, cancel := context.WithTimeout(ctx, retrieveChunkTimeout)
func (s *Service) handler(p2pctx context.Context, p p2p.Peer, stream p2p.Stream) (err error) {
ctx, cancel := context.WithTimeout(p2pctx, retrieveChunkTimeout)
defer cancel()

w, r := protobuf.NewWriterAndReader(stream)
Expand Down Expand Up @@ -486,7 +486,7 @@ func (s *Service) handler(ctx context.Context, p p2p.Peer, stream p2p.Stream) (e

// cache the request last, so that putting to the localstore does not slow down the request flow
if s.caching && forwarded {
if err := s.storer.Cache().Put(context.Background(), chunk); err != nil {
if err := s.storer.Cache().Put(p2pctx, chunk); err != nil {
s.logger.Debug("retrieve cache put", "error", err)
}
}
Expand Down

0 comments on commit 0d0c464

Please sign in to comment.