Skip to content

Commit

Permalink
fix(bitswap/server): pass context to server engine to register metrics (
Browse files Browse the repository at this point in the history
#723)

pass context to server engine to register metrics
  • Loading branch information
gammazero authored Nov 19, 2024
1 parent cfe68d8 commit 5929aca
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion bitswap/server/internal/decision/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion bitswap/server/internal/decision/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions bitswap/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 5929aca

Please sign in to comment.