diff options
author | obscuren <geffobscura@gmail.com> | 2015-02-17 23:12:55 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-02-17 23:12:55 +0800 |
commit | 567428fb3489d639cd7fdcd50e4362be52745ec4 (patch) | |
tree | 99e4353cc44bb392ef6583bb82a4e386ead6587c /core/filter.go | |
parent | 815ead71078d63c6d07cdee8b91679e307bedcb2 (diff) | |
download | go-tangerine-567428fb3489d639cd7fdcd50e4362be52745ec4.tar go-tangerine-567428fb3489d639cd7fdcd50e4362be52745ec4.tar.gz go-tangerine-567428fb3489d639cd7fdcd50e4362be52745ec4.tar.bz2 go-tangerine-567428fb3489d639cd7fdcd50e4362be52745ec4.tar.lz go-tangerine-567428fb3489d639cd7fdcd50e4362be52745ec4.tar.xz go-tangerine-567428fb3489d639cd7fdcd50e4362be52745ec4.tar.zst go-tangerine-567428fb3489d639cd7fdcd50e4362be52745ec4.zip |
Filter and mutex locks added
Diffstat (limited to 'core/filter.go')
-rw-r--r-- | core/filter.go | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/core/filter.go b/core/filter.go index 234fa3316..88f12a67c 100644 --- a/core/filter.go +++ b/core/filter.go @@ -16,7 +16,7 @@ type FilterOptions struct { Earliest int64 Latest int64 - Address []byte + Address [][]byte Topics [][]byte Skip int @@ -29,7 +29,7 @@ type Filter struct { earliest int64 latest int64 skip int - address []byte + address [][]byte max int topics [][]byte @@ -65,7 +65,7 @@ func (self *Filter) SetLatestBlock(latest int64) { self.latest = latest } -func (self *Filter) SetAddress(addr []byte) { +func (self *Filter) SetAddress(addr [][]byte) { self.address = addr } @@ -145,7 +145,8 @@ func (self *Filter) FilterLogs(logs state.Logs) state.Logs { // Filter the logs for interesting stuff Logs: for _, log := range logs { - if !bytes.Equal(self.address, log.Address()) { + if !includes(self.address, log.Address()) { + //if !bytes.Equal(self.address, log.Address()) { continue } @@ -163,8 +164,18 @@ Logs: } func (self *Filter) bloomFilter(block *types.Block) bool { - if len(self.address) > 0 && !types.BloomLookup(block.Bloom(), self.address) { - return false + if len(self.address) > 0 { + var included bool + for _, addr := range self.address { + if types.BloomLookup(block.Bloom(), addr) { + included = true + break + } + } + + if !included { + return false + } } for _, topic := range self.topics { |