mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
eth/filters: apply code review
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
ae21b5e081
commit
8345f8c253
2 changed files with 5 additions and 5 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue