Skip to content

Commit

Permalink
bitswap/client: remove providerQueryManager and move logic in session
Browse files Browse the repository at this point in the history
Closes: #172
See #172 (comment) for rational.
  • Loading branch information
Jorropo committed Dec 29, 2023
1 parent fda54dc commit 44421af
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 865 deletions.
21 changes: 3 additions & 18 deletions bitswap/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
bsmq "github.com/ipfs/boxo/bitswap/client/internal/messagequeue"
"github.com/ipfs/boxo/bitswap/client/internal/notifications"
bspm "github.com/ipfs/boxo/bitswap/client/internal/peermanager"
bspqm "github.com/ipfs/boxo/bitswap/client/internal/providerquerymanager"
"github.com/ipfs/boxo/bitswap/client/internal/session"

Check failure on line 16 in bitswap/client/client.go

View workflow job for this annotation

GitHub Actions / go-check / All

package "github.com/ipfs/boxo/bitswap/client/internal/session" is being imported more than once (ST1019)
bssession "github.com/ipfs/boxo/bitswap/client/internal/session"
bssim "github.com/ipfs/boxo/bitswap/client/internal/sessioninterestmanager"
bssm "github.com/ipfs/boxo/bitswap/client/internal/sessionmanager"
Expand Down Expand Up @@ -99,7 +99,7 @@ func WithoutDuplicatedBlockStats() Option {
}
}

type ContentSearcher = bspqm.ContentRouter
type ContentSearcher = session.ProviderFinder

// WithContentSearch allows the client to search for providers when it is not
// able to find the content itself.
Expand Down Expand Up @@ -155,11 +155,6 @@ func New(parent context.Context, network bsnet.BitSwapNetwork, bstore blockstore
option(bs)
}

if bs.router != nil {
bs.pqm = bspqm.New(ctx, network, bs.router)
bs.pqm.Startup()
}

// bind the context and process.
// do it over here to avoid closing before all setup is done.
go func() {
Expand All @@ -179,10 +174,6 @@ type Client struct {

pm *bspm.PeerManager

// the provider query manager manages requests to find providers
// is nil if content routing is disabled
pqm *bspqm.ProviderQueryManager

// network delivers messages on behalf of the session
network bsnet.BitSwapNetwork

Expand Down Expand Up @@ -244,13 +235,7 @@ func (bs *Client) sessionFactory(
rebroadcastDelay delay.D,
self peer.ID,
) bssm.Session {
// avoid typed nils
var pqm bssession.ProviderFinder
if bs.pqm != nil {
pqm = bs.pqm
}

return bssession.New(sessctx, sessmgr, id, spm, pqm, sim, pm, bpm, notif, provSearchDelay, rebroadcastDelay, self)
return bssession.New(sessctx, sessmgr, id, spm, sim, pm, bpm, notif, provSearchDelay, rebroadcastDelay, bs.router, bs.network)
}

// onDontHaveTimeout is called when a want-block is sent to a peer that
Expand Down
Loading

0 comments on commit 44421af

Please sign in to comment.