Skip to content

Commit

Permalink
separate context for pushsync replication (#1567)
Browse files Browse the repository at this point in the history
  • Loading branch information
ralph-pichler authored Apr 14, 2021
1 parent 3217c6e commit 393b51e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/pushsync/pushsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ func (ps *PushSync) handler(ctx context.Context, p p2p.Peer, stream p2p.Stream)
// price for neighborhood replication
receiptPrice := ps.pricer.PeerPrice(peer, chunk.Address())

ctx, cancel := context.WithTimeout(context.Background(), timeToWaitForPushsyncToNeighbor)
defer cancel()

err = ps.accounting.Reserve(ctx, peer, receiptPrice)
if err != nil {
err = fmt.Errorf("reserve balance for peer %s: %w", peer.String(), err)
Expand All @@ -214,8 +217,6 @@ func (ps *PushSync) handler(ctx context.Context, p p2p.Peer, stream p2p.Stream)
defer streamer.Close()

w := protobuf.NewWriter(streamer)
ctx, cancel := context.WithTimeout(ctx, timeToWaitForPushsyncToNeighbor)
defer cancel()

err = w.WriteMsgWithContext(ctx, &pb.Delivery{
Address: chunk.Address().Bytes(),
Expand Down

0 comments on commit 393b51e

Please sign in to comment.