aboutsummaryrefslogtreecommitdiffstats
path: root/eth/filters/filter.go
diff options
context:
space:
mode:
authorbas-vk <bas-vk@users.noreply.github.com>2016-11-28 21:59:06 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2016-11-28 21:59:06 +0800
commitb5be6b72cb06ded22075a41db6abc670d33c5ea7 (patch)
tree288845ba8db1db4d1e0d01ed612240c6229d8a9e /eth/filters/filter.go
parent318ad3c1e424912ff69c9febc4e08a0137f8803f (diff)
downloadgo-tangerine-b5be6b72cb06ded22075a41db6abc670d33c5ea7.tar
go-tangerine-b5be6b72cb06ded22075a41db6abc670d33c5ea7.tar.gz
go-tangerine-b5be6b72cb06ded22075a41db6abc670d33c5ea7.tar.bz2
go-tangerine-b5be6b72cb06ded22075a41db6abc670d33c5ea7.tar.lz
go-tangerine-b5be6b72cb06ded22075a41db6abc670d33c5ea7.tar.xz
go-tangerine-b5be6b72cb06ded22075a41db6abc670d33c5ea7.tar.zst
go-tangerine-b5be6b72cb06ded22075a41db6abc670d33c5ea7.zip
eth/filter: add support for pending logs (#3219)
Diffstat (limited to 'eth/filters/filter.go')
-rw-r--r--eth/filters/filter.go15
1 files changed, 11 insertions, 4 deletions
diff --git a/eth/filters/filter.go b/eth/filters/filter.go
index 4004af300..ce7383fb3 100644
--- a/eth/filters/filter.go
+++ b/eth/filters/filter.go
@@ -20,6 +20,8 @@ import (
"math"
"time"
+ "math/big"
+
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
@@ -162,7 +164,7 @@ func (f *Filter) getLogs(ctx context.Context, start, end uint64) (logs []Log, er
}
unfiltered = append(unfiltered, rl...)
}
- logs = append(logs, filterLogs(unfiltered, f.addresses, f.topics)...)
+ logs = append(logs, filterLogs(unfiltered, nil, nil, f.addresses, f.topics)...)
}
}
@@ -179,12 +181,18 @@ func includes(addresses []common.Address, a common.Address) bool {
return false
}
-func filterLogs(logs []Log, addresses []common.Address, topics [][]common.Hash) []Log {
+func filterLogs(logs []Log, fromBlock, toBlock *big.Int, addresses []common.Address, topics [][]common.Hash) []Log {
var ret []Log
-
// Filter the logs for interesting stuff
Logs:
for _, log := range logs {
+ if fromBlock != nil && fromBlock.Int64() >= 0 && uint64(fromBlock.Int64()) > log.BlockNumber {
+ continue
+ }
+ if toBlock != nil && toBlock.Int64() >= 0 && uint64(toBlock.Int64()) < log.BlockNumber {
+ continue
+ }
+
if len(addresses) > 0 && !includes(addresses, log.Address) {
continue
}
@@ -211,7 +219,6 @@ Logs:
continue Logs
}
}
-
ret = append(ret, log)
}