From 0ec73d639034781ac1283524633bd27d55683ea5 Mon Sep 17 00:00:00 2001 From: Alex Sharov Date: Thu, 30 Sep 2021 18:42:25 +0700 Subject: [PATCH] no panic on nil filters (#2751) --- cmd/rpcdaemon/commands/eth_filters.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/rpcdaemon/commands/eth_filters.go b/cmd/rpcdaemon/commands/eth_filters.go index 306c86a42..fcf17175a 100644 --- a/cmd/rpcdaemon/commands/eth_filters.go +++ b/cmd/rpcdaemon/commands/eth_filters.go @@ -39,6 +39,9 @@ func (api *APIImpl) GetFilterChanges(_ context.Context, index hexutil.Uint64) ([ // NewHeads send a notification each time a new (header) block is appended to the chain. func (api *APIImpl) NewHeads(ctx context.Context) (*rpc.Subscription, error) { + if api.filters == nil { + return &rpc.Subscription{}, rpc.ErrNotificationsUnsupported + } notifier, supported := rpc.NotifierFromContext(ctx) if !supported { return &rpc.Subscription{}, rpc.ErrNotificationsUnsupported @@ -71,6 +74,9 @@ func (api *APIImpl) NewHeads(ctx context.Context) (*rpc.Subscription, error) { // NewPendingTransactions send a notification each time a new (header) block is appended to the chain. func (api *APIImpl) NewPendingTransactions(ctx context.Context) (*rpc.Subscription, error) { + if api.filters == nil { + return &rpc.Subscription{}, rpc.ErrNotificationsUnsupported + } notifier, supported := rpc.NotifierFromContext(ctx) if !supported { return &rpc.Subscription{}, rpc.ErrNotificationsUnsupported