aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-04-24 19:36:34 +0800
committerobscuren <geffobscura@gmail.com>2015-04-24 19:45:21 +0800
commitcd2782f59c11ae8399dcdd17fdd2b132223a1071 (patch)
treec3f14e41485aa39bf85d251d3f595d4b83054232
parent31811365e0991a190748721d1549334043fda73c (diff)
downloadgo-tangerine-cd2782f59c11ae8399dcdd17fdd2b132223a1071.tar
go-tangerine-cd2782f59c11ae8399dcdd17fdd2b132223a1071.tar.gz
go-tangerine-cd2782f59c11ae8399dcdd17fdd2b132223a1071.tar.bz2
go-tangerine-cd2782f59c11ae8399dcdd17fdd2b132223a1071.tar.lz
go-tangerine-cd2782f59c11ae8399dcdd17fdd2b132223a1071.tar.xz
go-tangerine-cd2782f59c11ae8399dcdd17fdd2b132223a1071.tar.zst
go-tangerine-cd2782f59c11ae8399dcdd17fdd2b132223a1071.zip
core: fixed wildcard topic filters. Closes #725
-rw-r--r--core/filter.go19
1 files changed, 14 insertions, 5 deletions
diff --git a/core/filter.go b/core/filter.go
index a924709f2..c10fb7eeb 100644
--- a/core/filter.go
+++ b/core/filter.go
@@ -131,17 +131,26 @@ Logs:
logTopics := make([]common.Hash, len(self.topics))
copy(logTopics, log.Topics)
+ // If the to filtered topics is greater than the amount of topics in
+ // logs, skip.
+ if len(self.topics) > len(log.Topics) {
+ continue Logs
+ }
+
for i, topics := range self.topics {
+ var match bool
for _, topic := range topics {
- var match bool
// common.Hash{} is a match all (wildcard)
if (topic == common.Hash{}) || log.Topics[i] == topic {
match = true
- }
- if !match {
- continue Logs
+ break
}
}
+
+ if !match {
+ continue Logs
+ }
+
}
ret = append(ret, log)
@@ -168,7 +177,7 @@ func (self *Filter) bloomFilter(block *types.Block) bool {
for _, sub := range self.topics {
var included bool
for _, topic := range sub {
- if types.BloomLookup(block.Bloom(), topic) {
+ if (topic == common.Hash{}) || types.BloomLookup(block.Bloom(), topic) {
included = true
break
}