diff --git a/libs/service/service.go b/libs/service/service.go index f7701633a..6221c7d92 100644 --- a/libs/service/service.go +++ b/libs/service/service.go @@ -14,6 +14,11 @@ var ( errAlreadyStopped = errors.New("already stopped") ) +var ( + _ Service = (*BaseService)(nil) + _ Service = (*NopService)(nil) +) + // Service defines a service that can be started, stopped, and reset. type Service interface { // Start is called to start the service, which should run until @@ -85,6 +90,12 @@ type BaseService struct { impl Implementation } +type NopService struct{} + +func (NopService) Start(_ context.Context) error { return nil } +func (NopService) IsRunning() bool { return true } +func (NopService) Wait() {} + // NewBaseService creates a new BaseService. func NewBaseService(logger log.Logger, name string, impl Implementation) *BaseService { return &BaseService{ diff --git a/node/node.go b/node/node.go index 4bb72f4f6..3329d9f9a 100644 --- a/node/node.go +++ b/node/node.go @@ -357,7 +357,7 @@ func makeNode( return nil, combineCloseError(err, makeCloser(closers)) } - var pexReactor service.Service + var pexReactor service.Service = service.NopService{} if cfg.P2P.PexReactor { pexReactor, err = pex.NewReactor(ctx, logger, peerManager, router.OpenChannel, peerManager.Subscribe(ctx)) if err != nil {