184
}
185
}
186
187
-func mfsRootProvider(mfsRoot *mfs.Root) provider.KeyChanFunc {
188
- return func(ctx context.Context) (<-chan cid.Cid, error) {
189
- rootNode, err := mfsRoot.GetDirectory().GetNode()
190
- if err != nil {
191
- return nil, fmt.Errorf("error loading mfs root, cannot provide MFS: %w", err)
192
- }
193
- ch := make(chan cid.Cid, 1)
194
- ch <- rootNode.Cid()
195
- close(ch)
196
- return ch, nil
197
- }
198
-}
199
-
187
type provStrategyIn struct {
188
fx.In
189
Pinner pin.Pinner
206
// - "roots": Only root CIDs of pinned content
207
// - "pinned": All pinned content (roots + children)
208
// - "mfs": Only MFS content
222
-// - "flat": All blocks, no prioritization
223
-// - "all": Prioritized: pins first, then MFS roots, then all blocks
209
+// - "all": all blocks
210
func createKeyProvider(strategyFlag config.ReproviderStrategy, in provStrategyIn) provider.KeyChanFunc {
211
switch strategyFlag {
212
case config.ReproviderStrategyRoots:
220
)
221
case config.ReproviderStrategyMFS:
222
return mfsProvider(in.MFSRoot, in.OfflineUnixFSFetcher)
237
- case config.ReproviderStrategyFlat:
223
+ default: // "all", "", "flat" (compat)
224
return in.Blockstore.AllKeysChan
239
- default: // "all", ""
240
- return createAllStrategyProvider(in)
225
}
226
}
227
244
-// createAllStrategyProvider creates the complex "all" strategy provider.
245
-// This implements a three-tier priority system:
246
-// 1. Root blocks of direct and recursive pins (highest priority)
247
-// 2. MFS root (medium priority)
248
-// 3. All other blocks in blockstore (lowest priority)
249
-func createAllStrategyProvider(in provStrategyIn) provider.KeyChanFunc {
250
- return provider.NewPrioritizedProvider(
251
- provider.NewPrioritizedProvider(
252
- provider.NewBufferedProvider(dspinner.NewPinnedProvider(true, in.Pinner, in.OfflineIPLDFetcher)),
253
- mfsRootProvider(in.MFSRoot),
254
- ),
255
- in.Blockstore.AllKeysChan,
256
- )
257
-}
258
-
228
// detectStrategyChange checks if the reproviding strategy has changed from what's persisted.
229
// Returns: (previousStrategy, hasChanged, error)
230
func detectStrategyChange(ctx context.Context, strategy string, ds datastore.Datastore) (string, bool, error) {