Skip to content

Commit 2a669d8

Browse files
fix: SweepingProvider shouldn't error when missing DHT (#10975)
* fix: SweepingProvider shouldn't error when missing DHT * fix: prevent panic when SweepingProvider has no DHT when SweepingProvider is enabled but no DHT is available (e.g., Routing.Type=none), the daemon would panic with a nil pointer dereference in ResettableKeystore.ResetCids. this fix: - returns NoopProvider when no DHT implementation is available - skips keystore initialization for NoopProvider to avoid unnecessary operations - allows nodes to run without DHT when using HTTP-only routing or offline mode the panic occurred because initKeyStore tried to access a nil keystore when SweepingProvider returned nil for the keystore parameter. by checking if the provider is NoopProvider and skipping keystore operations, we avoid the panic while maintaining correct behavior for all other provider types. cc #10974 #10975 --------- Co-authored-by: Marcin Rataj <[email protected]>
1 parent 9c2c541 commit 2a669d8

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

core/node/provider.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -355,13 +355,7 @@ func SweepingProviderOpt(cfg *config.Config) fx.Option {
355355
}
356356
}
357357
if impl == nil {
358-
// No DHT available, check if HTTP provider is configured
359-
cfg, err := in.Repo.Config()
360-
if err == nil && cfg.HasHTTPProviderConfigured() {
361-
// HTTP provider is configured, return NoopProvider to allow HTTP-based providing
362-
return &NoopProvider{}, keyStore, nil
363-
}
364-
return &NoopProvider{}, nil, errors.New("provider: no valid DHT available for providing")
358+
return &NoopProvider{}, nil, nil
365359
}
366360

367361
var selfAddrsFunc func() []ma.Multiaddr
@@ -403,6 +397,11 @@ func SweepingProviderOpt(cfg *config.Config) fx.Option {
403397
KeyProvider provider.KeyChanFunc
404398
}
405399
initKeyStore := fx.Invoke(func(lc fx.Lifecycle, in keystoreInput) {
400+
// Skip keystore initialization for NoopProvider
401+
if _, ok := in.Provider.(*NoopProvider); ok {
402+
return
403+
}
404+
406405
var (
407406
cancel context.CancelFunc
408407
done = make(chan struct{})

0 commit comments

Comments
 (0)