mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-20 21:54:30 +00:00
This commit is contained in:
parent
35e5143fe7
commit
7b92ec7d5a
2 changed files with 7 additions and 0 deletions
|
|
@ -300,6 +300,9 @@ func (es *EventSystem) subscribe(sub *subscription) *Subscription {
|
|||
// given criteria to the given logs channel. Default value for the from and to
|
||||
// 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, errExceedMaxTopics
|
||||
}
|
||||
var from, to rpc.BlockNumber
|
||||
if crit.FromBlock == nil {
|
||||
from = rpc.LatestBlockNumber
|
||||
|
|
|
|||
|
|
@ -320,6 +320,8 @@ func TestLogFilterCreation(t *testing.T) {
|
|||
{FilterCriteria{FromBlock: big.NewInt(rpc.PendingBlockNumber.Int64()), ToBlock: big.NewInt(100)}, false},
|
||||
// from block "higher" than to block
|
||||
{FilterCriteria{FromBlock: big.NewInt(rpc.PendingBlockNumber.Int64()), ToBlock: big.NewInt(rpc.LatestBlockNumber.Int64())}, false},
|
||||
// topics more than 4
|
||||
{FilterCriteria{Topics: [][]common.Hash{{}, {}, {}, {}, {}}}, false},
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -351,6 +353,7 @@ func TestInvalidLogFilterCreation(t *testing.T) {
|
|||
0: {FromBlock: big.NewInt(rpc.PendingBlockNumber.Int64()), ToBlock: big.NewInt(rpc.LatestBlockNumber.Int64())},
|
||||
1: {FromBlock: big.NewInt(rpc.PendingBlockNumber.Int64()), ToBlock: big.NewInt(100)},
|
||||
2: {FromBlock: big.NewInt(rpc.LatestBlockNumber.Int64()), ToBlock: big.NewInt(100)},
|
||||
3: {Topics: [][]common.Hash{{}, {}, {}, {}, {}}},
|
||||
}
|
||||
|
||||
for i, test := range testCases {
|
||||
|
|
@ -376,6 +379,7 @@ func TestInvalidGetLogsRequest(t *testing.T) {
|
|||
0: {BlockHash: &blockHash, FromBlock: big.NewInt(100)},
|
||||
1: {BlockHash: &blockHash, ToBlock: big.NewInt(500)},
|
||||
2: {BlockHash: &blockHash, FromBlock: big.NewInt(rpc.LatestBlockNumber.Int64())},
|
||||
3: {BlockHash: &blockHash, Topics: [][]common.Hash{{}, {}, {}, {}, {}}},
|
||||
}
|
||||
|
||||
for i, test := range testCases {
|
||||
|
|
|
|||
Loading…
Reference in a new issue