mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-25 13:07:17 +00:00
Merge pull request #803 from obscuren/log_filter_fixes
core: fixed wildcard topic filters. Closes #725
This commit is contained in:
commit
c8e21a4d17
@ -131,17 +131,26 @@ Logs:
|
|||||||
logTopics := make([]common.Hash, len(self.topics))
|
logTopics := make([]common.Hash, len(self.topics))
|
||||||
copy(logTopics, log.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 {
|
for i, topics := range self.topics {
|
||||||
|
var match bool
|
||||||
for _, topic := range topics {
|
for _, topic := range topics {
|
||||||
var match bool
|
|
||||||
// common.Hash{} is a match all (wildcard)
|
// common.Hash{} is a match all (wildcard)
|
||||||
if (topic == common.Hash{}) || log.Topics[i] == topic {
|
if (topic == common.Hash{}) || log.Topics[i] == topic {
|
||||||
match = true
|
match = true
|
||||||
}
|
break
|
||||||
if !match {
|
|
||||||
continue Logs
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !match {
|
||||||
|
continue Logs
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = append(ret, log)
|
ret = append(ret, log)
|
||||||
@ -168,7 +177,7 @@ func (self *Filter) bloomFilter(block *types.Block) bool {
|
|||||||
for _, sub := range self.topics {
|
for _, sub := range self.topics {
|
||||||
var included bool
|
var included bool
|
||||||
for _, topic := range sub {
|
for _, topic := range sub {
|
||||||
if types.BloomLookup(block.Bloom(), topic) {
|
if (topic == common.Hash{}) || types.BloomLookup(block.Bloom(), topic) {
|
||||||
included = true
|
included = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user