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) too.

providerQueryManager took care of:
- Deduping multiple sessions doing find providers for the same CID.
- limiting global find providers.

None of which we care:
- This is rare, if this happens it's fine to run the same query twice.
  If we care then we should make a deduping content router so we can inject it anywhere a content router is needed.
- It's fine to allow one concurrent find peer per session. No need to limit this at 6 globally after that, it's a great way to stall nodes doing many queries.
  • Loading branch information
Jorropo committed Jan 3, 2024
1 parent 2a2f368 commit efaeefb
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 865 deletions.
20 changes: 2 additions & 18 deletions bitswap/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ 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"
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 +98,7 @@ func WithoutDuplicatedBlockStats() Option {
}
}

type ContentSearcher = bspqm.ContentRouter
type ContentSearcher = bssession.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 +154,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 +173,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 +234,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 efaeefb

Please sign in to comment.