Skip to content

Commit 7c8e299

Browse files
not supplying DHT shouldn't make fx fail
1 parent 1719d77 commit 7c8e299

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

core/node/provider.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ func SweepingProviderOpt(cfg *config.Config) fx.Option {
344344
}
345345
}
346346
if impl == nil {
347-
return &NoopProvider{}, nil, errors.New("no valid DHT available for providing")
347+
return &NoopProvider{}, nil, nil
348348
}
349349

350350
var selfAddrsFunc func() []ma.Multiaddr
@@ -407,6 +407,9 @@ func SweepingProviderOpt(cfg *config.Config) fx.Option {
407407

408408
lc.Append(fx.Hook{
409409
OnStart: func(ctx context.Context) error {
410+
if in.Provider == nil || in.KeyStore == nil {
411+
return nil
412+
}
410413
// Set the KeyProvider as a garbage collection function for the
411414
// keystore. Periodically purge the KeyStore from all its keys and
412415
// replace them with the keys that needs to be reprovided, coming from
@@ -438,6 +441,10 @@ func SweepingProviderOpt(cfg *config.Config) fx.Option {
438441
return nil
439442
},
440443
OnStop: func(ctx context.Context) error {
444+
if in.Provider == nil || in.KeyStore == nil {
445+
return nil
446+
}
447+
441448
if cancel != nil {
442449
// Cancel KeyStore garbage collection loop
443450
cancel()

0 commit comments

Comments
 (0)