aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain/bloom9.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-10-30 03:16:18 +0800
committerobscuren <geffobscura@gmail.com>2014-10-30 03:16:18 +0800
commitcc67a84e945ba914d8e4981106d3c75c91c00db0 (patch)
treee409cf6b53a5a6308899958bb93f979c90b8c9de /ethchain/bloom9.go
parent81ec564ef61a6dcd06cfdd98a515d366aaac719f (diff)
downloaddexon-cc67a84e945ba914d8e4981106d3c75c91c00db0.tar
dexon-cc67a84e945ba914d8e4981106d3c75c91c00db0.tar.gz
dexon-cc67a84e945ba914d8e4981106d3c75c91c00db0.tar.bz2
dexon-cc67a84e945ba914d8e4981106d3c75c91c00db0.tar.lz
dexon-cc67a84e945ba914d8e4981106d3c75c91c00db0.tar.xz
dexon-cc67a84e945ba914d8e4981106d3c75c91c00db0.tar.zst
dexon-cc67a84e945ba914d8e4981106d3c75c91c00db0.zip
Added bloom 9 point lookup and bloom test
Diffstat (limited to 'ethchain/bloom9.go')
-rw-r--r--ethchain/bloom9.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/ethchain/bloom9.go b/ethchain/bloom9.go
index 508644b62..e841e7af7 100644
--- a/ethchain/bloom9.go
+++ b/ethchain/bloom9.go
@@ -3,6 +3,7 @@ package ethchain
import (
"math/big"
+ "github.com/ethereum.backup/ethutil-go"
"github.com/ethereum/go-ethereum/vm"
)
@@ -23,7 +24,10 @@ func LogsBloom(logs []vm.Log) *big.Int {
for _, topic := range log.Topics {
data = append(data, topic)
}
- data = append(data, log.Data)
+
+ if log.Data != nil {
+ data = append(data, log.Data)
+ }
for _, b := range data {
bin.Or(bin, bloom9(b))
@@ -42,3 +46,10 @@ func bloom9(b []byte) *big.Int {
return r
}
+
+func BloomLookup(bin, topic []byte) bool {
+ bloom := ethutil.BigD(bin)
+ cmp := bloom9(topic)
+
+ return bloom.And(bloom, cmp).Cmp(cmp) == 0
+}