@@ -428,9 +428,18 @@ func SweepingProviderOpt(cfg *config.Config) fx.Option {
428
428
// replace them with the keys that needs to be reprovided, coming from
429
429
// the KeyChanFunc. So far, this is the less worse way to remove CIDs
430
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
+ }()
434
443
435
444
gcCtx , c := context .WithCancel (context .Background ())
436
445
cancel = c
@@ -462,10 +471,10 @@ func SweepingProviderOpt(cfg *config.Config) fx.Option {
462
471
case <- ctx .Done ():
463
472
return ctx .Err ()
464
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
+
469
478
return in .KeyStore .Close ()
470
479
},
471
480
})
0 commit comments