Skip to content

Commit a04b38e

Browse files
committed
bitswap/client: remove providerQueryManager and move logic in session
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.
1 parent fda54dc commit a04b38e

File tree

5 files changed

+106
-865
lines changed

5 files changed

+106
-865
lines changed

bitswap/client/client.go

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
bsmq "github.com/ipfs/boxo/bitswap/client/internal/messagequeue"
1414
"github.com/ipfs/boxo/bitswap/client/internal/notifications"
1515
bspm "github.com/ipfs/boxo/bitswap/client/internal/peermanager"
16-
bspqm "github.com/ipfs/boxo/bitswap/client/internal/providerquerymanager"
1716
bssession "github.com/ipfs/boxo/bitswap/client/internal/session"
1817
bssim "github.com/ipfs/boxo/bitswap/client/internal/sessioninterestmanager"
1918
bssm "github.com/ipfs/boxo/bitswap/client/internal/sessionmanager"
@@ -99,7 +98,7 @@ func WithoutDuplicatedBlockStats() Option {
9998
}
10099
}
101100

102-
type ContentSearcher = bspqm.ContentRouter
101+
type ContentSearcher = bssession.ProviderFinder
103102

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

158-
if bs.router != nil {
159-
bs.pqm = bspqm.New(ctx, network, bs.router)
160-
bs.pqm.Startup()
161-
}
162-
163157
// bind the context and process.
164158
// do it over here to avoid closing before all setup is done.
165159
go func() {
@@ -179,10 +173,6 @@ type Client struct {
179173

180174
pm *bspm.PeerManager
181175

182-
// the provider query manager manages requests to find providers
183-
// is nil if content routing is disabled
184-
pqm *bspqm.ProviderQueryManager
185-
186176
// network delivers messages on behalf of the session
187177
network bsnet.BitSwapNetwork
188178

@@ -244,13 +234,7 @@ func (bs *Client) sessionFactory(
244234
rebroadcastDelay delay.D,
245235
self peer.ID,
246236
) bssm.Session {
247-
// avoid typed nils
248-
var pqm bssession.ProviderFinder
249-
if bs.pqm != nil {
250-
pqm = bs.pqm
251-
}
252-
253-
return bssession.New(sessctx, sessmgr, id, spm, pqm, sim, pm, bpm, notif, provSearchDelay, rebroadcastDelay, self)
237+
return bssession.New(sessctx, sessmgr, id, spm, sim, pm, bpm, notif, provSearchDelay, rebroadcastDelay, bs.router, bs.network)
254238
}
255239

256240
// onDontHaveTimeout is called when a want-block is sent to a peer that

0 commit comments

Comments
 (0)