aboutsummaryrefslogtreecommitdiffstats
path: root/eth/filters/api.go
diff options
context:
space:
mode:
authorzsfelfoldi <zsfelfoldi@gmail.com>2016-01-14 02:35:48 +0800
committerFelix Lange <fjl@twurst.com>2016-11-09 09:12:53 +0800
commit7db7109a5b53c339f00e9c05ac826b3dbd1f98e1 (patch)
treec447d9816c4490e71cb2a8d2420d82f938d8757a /eth/filters/api.go
parent9f8d192991c4f68fa14c91366722bbca601da117 (diff)
downloadgo-tangerine-7db7109a5b53c339f00e9c05ac826b3dbd1f98e1.tar
go-tangerine-7db7109a5b53c339f00e9c05ac826b3dbd1f98e1.tar.gz
go-tangerine-7db7109a5b53c339f00e9c05ac826b3dbd1f98e1.tar.bz2
go-tangerine-7db7109a5b53c339f00e9c05ac826b3dbd1f98e1.tar.lz
go-tangerine-7db7109a5b53c339f00e9c05ac826b3dbd1f98e1.tar.xz
go-tangerine-7db7109a5b53c339f00e9c05ac826b3dbd1f98e1.tar.zst
go-tangerine-7db7109a5b53c339f00e9c05ac826b3dbd1f98e1.zip
cmd, eth: added light client and light server modes
Diffstat (limited to 'eth/filters/api.go')
-rw-r--r--eth/filters/api.go18
1 files changed, 11 insertions, 7 deletions
diff --git a/eth/filters/api.go b/eth/filters/api.go
index fa4bef283..834513262 100644
--- a/eth/filters/api.go
+++ b/eth/filters/api.go
@@ -52,6 +52,8 @@ type filter struct {
// PublicFilterAPI offers support to create and manage filters. This will allow external clients to retrieve various
// information related to the Ethereum protocol such als blocks, transactions and logs.
type PublicFilterAPI struct {
+ backend Backend
+ useMipMap bool
mux *event.TypeMux
quit chan struct{}
chainDb ethdb.Database
@@ -316,7 +318,7 @@ func (api *PublicFilterAPI) NewFilter(crit FilterCriteria) rpc.ID {
// GetLogs returns logs matching the given argument that are stored within the state.
//
// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getlogs
-func (api *PublicFilterAPI) GetLogs(crit FilterCriteria) []Log {
+func (api *PublicFilterAPI) GetLogs(ctx context.Context, crit FilterCriteria) ([]Log, error) {
if crit.FromBlock == nil {
crit.FromBlock = big.NewInt(rpc.LatestBlockNumber.Int64())
}
@@ -324,13 +326,14 @@ func (api *PublicFilterAPI) GetLogs(crit FilterCriteria) []Log {
crit.ToBlock = big.NewInt(rpc.LatestBlockNumber.Int64())
}
- filter := New(api.chainDb)
+ filter := New(api.backend, api.useMipMap)
filter.SetBeginBlock(crit.FromBlock.Int64())
filter.SetEndBlock(crit.ToBlock.Int64())
filter.SetAddresses(crit.Addresses)
filter.SetTopics(crit.Topics)
- return returnLogs(filter.Find())
+ logs, err := filter.Find(ctx)
+ return returnLogs(logs), err
}
// UninstallFilter removes the filter with the given filter id.
@@ -354,22 +357,23 @@ func (api *PublicFilterAPI) UninstallFilter(id rpc.ID) bool {
// If the filter could not be found an empty array of logs is returned.
//
// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getfilterlogs
-func (api *PublicFilterAPI) GetFilterLogs(id rpc.ID) []Log {
+func (api *PublicFilterAPI) GetFilterLogs(ctx context.Context, id rpc.ID) ([]Log, error) {
api.filtersMu.Lock()
f, found := api.filters[id]
api.filtersMu.Unlock()
if !found || f.typ != LogsSubscription {
- return []Log{}
+ return []Log{}, nil
}
- filter := New(api.chainDb)
+ filter := New(api.backend, api.useMipMap)
filter.SetBeginBlock(f.crit.FromBlock.Int64())
filter.SetEndBlock(f.crit.ToBlock.Int64())
filter.SetAddresses(f.crit.Addresses)
filter.SetTopics(f.crit.Topics)
- return returnLogs(filter.Find())
+ logs, err := filter.Find(ctx)
+ return returnLogs(logs), err
}
// GetFilterChanges returns the logs for the filter with the given id since