diff options
author | Zsolt Felfoldi <zsfelfoldi@gmail.com> | 2017-09-06 08:33:10 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-09-06 16:14:21 +0800 |
commit | 451ffdb62b43bab66188f3f7eeb2131b65415ccb (patch) | |
tree | d13c6e0a01d22e90c0f3222dcd261255b5dd1efb /eth | |
parent | 6ff2c02991e60a8db54c2f60027442277fd889c0 (diff) | |
download | dexon-451ffdb62b43bab66188f3f7eeb2131b65415ccb.tar.gz dexon-451ffdb62b43bab66188f3f7eeb2131b65415ccb.tar.zst dexon-451ffdb62b43bab66188f3f7eeb2131b65415ccb.zip |
core/bloombits: use general filters instead of addresses and topics
Diffstat (limited to 'eth')
-rw-r--r-- | eth/filters/filter.go | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/eth/filters/filter.go b/eth/filters/filter.go index 3a2226f6b..4f6c30058 100644 --- a/eth/filters/filter.go +++ b/eth/filters/filter.go @@ -60,6 +60,23 @@ type Filter struct { // New creates a new filter which uses a bloom filter on blocks to figure out whether // a particular block is interesting or not. func New(backend Backend, begin, end int64, addresses []common.Address, topics [][]common.Hash) *Filter { + // Flatten the address and topic filter clauses into a single filter system + var filters [][][]byte + if len(addresses) > 0 { + filter := make([][]byte, len(addresses)) + for i, address := range addresses { + filter[i] = address.Bytes() + } + filters = append(filters, filter) + } + for _, topicList := range topics { + filter := make([][]byte, len(topicList)) + for i, topic := range topicList { + filter[i] = topic.Bytes() + } + filters = append(filters, filter) + } + // Assemble and return the filter size, _ := backend.BloomStatus() return &Filter{ @@ -69,7 +86,7 @@ func New(backend Backend, begin, end int64, addresses []common.Address, topics [ addresses: addresses, topics: topics, db: backend.ChainDb(), - matcher: bloombits.NewMatcher(size, addresses, topics), + matcher: bloombits.NewMatcher(size, filters), } } |