diff --git a/bitswap/server/internal/decision/engine.go b/bitswap/server/internal/decision/engine.go index a46d67dd7..9b929b99c 100644 --- a/bitswap/server/internal/decision/engine.go +++ b/bitswap/server/internal/decision/engine.go @@ -378,12 +378,13 @@ func wrapTaskComparator(tc TaskComparator) peertask.QueueTaskComparator { // maxOutstandingBytesPerPeer hints to the peer task queue not to give a peer // more tasks if it has some maximum work already outstanding. func NewEngine( + ctx context.Context, bs bstore.Blockstore, peerTagger PeerTagger, self peer.ID, opts ...Option, ) *Engine { - ctx, cancel := context.WithCancel(context.Background()) + ctx, cancel := context.WithCancel(ctx) e := &Engine{ scoreLedger: NewDefaultScoreLedger(), diff --git a/bitswap/server/internal/decision/engine_test.go b/bitswap/server/internal/decision/engine_test.go index d549e1218..cab5b5691 100644 --- a/bitswap/server/internal/decision/engine_test.go +++ b/bitswap/server/internal/decision/engine_test.go @@ -188,7 +188,7 @@ func newEngineForTesting( opts ...Option, ) *Engine { opts = append(opts, WithWantHaveReplaceSize(wantHaveReplaceSize)) - return NewEngine(bs, peerTagger, self, opts...) + return NewEngine(context.Background(), bs, peerTagger, self, opts...) } func TestOutboxClosedWhenEngineClosed(t *testing.T) { diff --git a/bitswap/server/server.go b/bitswap/server/server.go index 2cc3e2474..6416da034 100644 --- a/bitswap/server/server.go +++ b/bitswap/server/server.go @@ -99,6 +99,7 @@ func New(ctx context.Context, network bsnet.BitSwapNetwork, bstore blockstore.Bl } s.engine = decision.NewEngine( + ctx, bstore, network.ConnectionManager(), network.Self(),