mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-06 16:58:11 +08:00
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>
(cherry picked from commit 1e9b6fb27e)
This commit is contained in:
parent
cb61218552
commit
fa033036d3
@ -428,9 +428,18 @@ func SweepingProviderOpt(cfg *config.Config) fx.Option {
|
||||
// replace them with the keys that needs to be reprovided, coming from
|
||||
// the KeyChanFunc. So far, this is the less worse way to remove CIDs
|
||||
// that shouldn't be reprovided from the provider's state.
|
||||
if err := syncKeyStore(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
go func() {
|
||||
// Sync the keystore once at startup. This operation is async since
|
||||
// we need to walk the DAG of objects matching the provide strategy,
|
||||
// which can take a while.
|
||||
strategy := cfg.Provide.Strategy.WithDefault(config.DefaultProvideStrategy)
|
||||
logger.Infow("provider keystore sync started", "strategy", strategy)
|
||||
if err := syncKeyStore(ctx); err != nil {
|
||||
logger.Errorw("provider keystore sync failed", "err", err, "strategy", strategy)
|
||||
} else {
|
||||
logger.Infow("provider keystore sync completed", "strategy", strategy)
|
||||
}
|
||||
}()
|
||||
|
||||
gcCtx, c := context.WithCancel(context.Background())
|
||||
cancel = c
|
||||
@ -462,10 +471,10 @@ func SweepingProviderOpt(cfg *config.Config) fx.Option {
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
}
|
||||
// KeyStore state isn't be persisted across restarts.
|
||||
if err := in.KeyStore.Empty(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Keystore data isn't purged, on close, but it will be overwritten
|
||||
// when the node starts again.
|
||||
|
||||
return in.KeyStore.Close()
|
||||
},
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user