@cryptotaxi247 / kubo / commits / 1e9b6fb27

fix: SweepingProvider slow start (#10980)

* fix: SweepingProvider slow start #10979 * don't purge keystore * feat: add INFO logging for provider keystore sync log start/completion of async keystore sync with strategy --------- Co-authored-by: Marcin Rataj <lidel@lidel.org>

Guillaume Michel committed Sep 25, 2025 at 17:11 UTC 1e9b6fb27e43fb181d28801fe4f5121c688a2d31
1 file changed +16 -7
core/node/provider.go
+16 -7
@@ -428,9 +428,18 @@ func SweepingProviderOpt(cfg *config.Config) fx.Option {
428 // replace them with the keys that needs to be reprovided, coming from
429 // the KeyChanFunc. So far, this is the less worse way to remove CIDs
430 // that shouldn't be reprovided from the provider's state.
431 - if err := syncKeyStore(ctx); err != nil {
432 - return err
433 - }
431 + go func() {
432 + // Sync the keystore once at startup. This operation is async since
433 + // we need to walk the DAG of objects matching the provide strategy,
434 + // which can take a while.
435 + strategy := cfg.Provide.Strategy.WithDefault(config.DefaultProvideStrategy)
436 + logger.Infow("provider keystore sync started", "strategy", strategy)
437 + if err := syncKeyStore(ctx); err != nil {
438 + logger.Errorw("provider keystore sync failed", "err", err, "strategy", strategy)
439 + } else {
440 + logger.Infow("provider keystore sync completed", "strategy", strategy)
441 + }
442 + }()
443
444 gcCtx, c := context.WithCancel(context.Background())
445 cancel = c
@@ -462,10 +471,10 @@ func SweepingProviderOpt(cfg *config.Config) fx.Option {
471 case <-ctx.Done():
472 return ctx.Err()
473 }
465 - // KeyStore state isn't be persisted across restarts.
466 - if err := in.KeyStore.Empty(ctx); err != nil {
467 - return err
468 - }
474 +
475 + // Keystore data isn't purged, on close, but it will be overwritten
476 + // when the node starts again.
477 +
478 return in.KeyStore.Close()
479 },
480 })