diff --git a/eth/filters/api.go b/eth/filters/api.go index 1a926fe14d..a4eaa9cec8 100644 --- a/eth/filters/api.go +++ b/eth/filters/api.go @@ -29,7 +29,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/internal/ethapi" "github.com/ethereum/go-ethereum/rpc" ) @@ -38,10 +37,11 @@ var ( errInvalidTopic = errors.New("invalid topic(s)") errFilterNotFound = errors.New("filter not found") errInvalidBlockRange = errors.New("invalid block range params") + errExceedMaxTopics = errors.New("exceed max topics") ) -// The maximum number of topic criteria allowed -const maxTopics = int(vm.LOG4 - vm.LOG0) +// The maximum number of topic criteria allowed, vm.LOG4 - vm.LOG0 +const maxTopics = 4 // filter is a helper struct that holds meta information over the filter type // and associated subscription in the event system. @@ -339,7 +339,7 @@ func (api *FilterAPI) NewFilter(crit FilterCriteria) (rpc.ID, error) { // GetLogs returns logs matching the given argument that are stored within the state. func (api *FilterAPI) GetLogs(ctx context.Context, crit FilterCriteria) ([]*types.Log, error) { if len(crit.Topics) > maxTopics { - return nil, errInvalidTopic + return nil, errExceedMaxTopics } var filter *Filter if crit.BlockHash != nil { diff --git a/eth/filters/filter_system.go b/eth/filters/filter_system.go index 839caea9cf..f98a1f84ce 100644 --- a/eth/filters/filter_system.go +++ b/eth/filters/filter_system.go @@ -300,7 +300,7 @@ func (es *EventSystem) subscribe(sub *subscription) *Subscription { // block is "latest". If the fromBlock > toBlock an error is returned. func (es *EventSystem) SubscribeLogs(crit ethereum.FilterQuery, logs chan []*types.Log) (*Subscription, error) { if len(crit.Topics) > maxTopics { - return nil, errInvalidTopic + return nil, errExceedMaxTopics } var from, to rpc.BlockNumber if crit.FromBlock == nil {