Commit 393b51e6 authored by Ralph Pichler's avatar Ralph Pichler Committed by GitHub

separate context for pushsync replication (#1567)

parent 3217c6e1
...@@ -199,6 +199,9 @@ func (ps *PushSync) handler(ctx context.Context, p p2p.Peer, stream p2p.Stream) ...@@ -199,6 +199,9 @@ func (ps *PushSync) handler(ctx context.Context, p p2p.Peer, stream p2p.Stream)
// price for neighborhood replication // price for neighborhood replication
receiptPrice := ps.pricer.PeerPrice(peer, chunk.Address()) receiptPrice := ps.pricer.PeerPrice(peer, chunk.Address())
ctx, cancel := context.WithTimeout(context.Background(), timeToWaitForPushsyncToNeighbor)
defer cancel()
err = ps.accounting.Reserve(ctx, peer, receiptPrice) err = ps.accounting.Reserve(ctx, peer, receiptPrice)
if err != nil { if err != nil {
err = fmt.Errorf("reserve balance for peer %s: %w", peer.String(), err) err = fmt.Errorf("reserve balance for peer %s: %w", peer.String(), err)
...@@ -214,8 +217,6 @@ func (ps *PushSync) handler(ctx context.Context, p p2p.Peer, stream p2p.Stream) ...@@ -214,8 +217,6 @@ func (ps *PushSync) handler(ctx context.Context, p p2p.Peer, stream p2p.Stream)
defer streamer.Close() defer streamer.Close()
w := protobuf.NewWriter(streamer) w := protobuf.NewWriter(streamer)
ctx, cancel := context.WithTimeout(ctx, timeToWaitForPushsyncToNeighbor)
defer cancel()
err = w.WriteMsgWithContext(ctx, &pb.Delivery{ err = w.WriteMsgWithContext(ctx, &pb.Delivery{
Address: chunk.Address().Bytes(), Address: chunk.Address().Bytes(),
......
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