aboutsummaryrefslogtreecommitdiffstats
path: root/accounts
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2018-07-24 17:52:16 +0800
committerGitHub <noreply@github.com>2018-07-24 17:52:16 +0800
commit21c059b67ef4da979db3d66bd021a72112b35419 (patch)
tree70881528b2f4ab1b36b4892f9e92cefc753e6d55 /accounts
parent9e24491c65120d3fb36da45e57a0cb87c549f621 (diff)
parente1f1d3085c6b868de93313700cac8a325e9b148b (diff)
downloadgo-tangerine-21c059b67ef4da979db3d66bd021a72112b35419.tar
go-tangerine-21c059b67ef4da979db3d66bd021a72112b35419.tar.gz
go-tangerine-21c059b67ef4da979db3d66bd021a72112b35419.tar.bz2
go-tangerine-21c059b67ef4da979db3d66bd021a72112b35419.tar.lz
go-tangerine-21c059b67ef4da979db3d66bd021a72112b35419.tar.xz
go-tangerine-21c059b67ef4da979db3d66bd021a72112b35419.tar.zst
go-tangerine-21c059b67ef4da979db3d66bd021a72112b35419.zip
Merge pull request #16734 from reductionista/eip234
eth/filters, interfaces: EIP-234 Add blockHash option to eth_getLogs
Diffstat (limited to 'accounts')
-rw-r--r--accounts/abi/bind/backends/simulated.go32
1 files changed, 21 insertions, 11 deletions
diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go
index fd69538d5..fa8828f61 100644
--- a/accounts/abi/bind/backends/simulated.go
+++ b/accounts/abi/bind/backends/simulated.go
@@ -324,18 +324,24 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transa
//
// TODO(karalabe): Deprecate when the subscription one can return past data too.
func (b *SimulatedBackend) FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error) {
- // Initialize unset filter boundaried to run from genesis to chain head
- from := int64(0)
- if query.FromBlock != nil {
- from = query.FromBlock.Int64()
- }
- to := int64(-1)
- if query.ToBlock != nil {
- to = query.ToBlock.Int64()
+ var filter *filters.Filter
+ if query.BlockHash != nil {
+ // Block filter requested, construct a single-shot filter
+ filter = filters.NewBlockFilter(&filterBackend{b.database, b.blockchain}, *query.BlockHash, query.Addresses, query.Topics)
+ } else {
+ // Initialize unset filter boundaried to run from genesis to chain head
+ from := int64(0)
+ if query.FromBlock != nil {
+ from = query.FromBlock.Int64()
+ }
+ to := int64(-1)
+ if query.ToBlock != nil {
+ to = query.ToBlock.Int64()
+ }
+ // Construct the range filter
+ filter = filters.NewRangeFilter(&filterBackend{b.database, b.blockchain}, from, to, query.Addresses, query.Topics)
}
- // Construct and execute the filter
- filter := filters.New(&filterBackend{b.database, b.blockchain}, from, to, query.Addresses, query.Topics)
-
+ // Run the filter and return all the logs
logs, err := filter.Logs(ctx)
if err != nil {
return nil, err
@@ -430,6 +436,10 @@ func (fb *filterBackend) HeaderByNumber(ctx context.Context, block rpc.BlockNumb
return fb.bc.GetHeaderByNumber(uint64(block.Int64())), nil
}
+func (fb *filterBackend) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error) {
+ return fb.bc.GetHeaderByHash(hash), nil
+}
+
func (fb *filterBackend) GetReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error) {
number := rawdb.ReadHeaderNumber(fb.db, hash)
if number == nil {