aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain/bloom9.go
diff options
context:
space:
mode:
Diffstat (limited to 'ethchain/bloom9.go')
-rw-r--r--ethchain/bloom9.go31
1 files changed, 19 insertions, 12 deletions
diff --git a/ethchain/bloom9.go b/ethchain/bloom9.go
index 65be6c7a2..742610169 100644
--- a/ethchain/bloom9.go
+++ b/ethchain/bloom9.go
@@ -1,37 +1,44 @@
package ethchain
-import "github.com/ethereum/go-ethereum/vm"
+import (
+ "math/big"
-func CreateBloom(txs Transactions) uint64 {
- var bin uint64
+ "github.com/ethereum/go-ethereum/vm"
+)
+
+func CreateBloom(txs Transactions) []byte {
+ bin := new(big.Int)
for _, tx := range txs {
- bin |= logsBloom(tx.logs)
+ bin.Or(bin, LogsBloom(tx.logs))
}
- return bin
+ return bin.Bytes()
}
-func logsBloom(logs []vm.Log) uint64 {
- var bin uint64
+func LogsBloom(logs []vm.Log) *big.Int {
+ bin := new(big.Int)
for _, log := range logs {
data := [][]byte{log.Address}
for _, topic := range log.Topics {
- data = append(data, topic.Bytes())
+ data = append(data, topic)
}
data = append(data, log.Data)
for _, b := range data {
- bin |= bloom9(b)
+ bin.Or(bin, bloom9(b))
}
}
return bin
}
-func bloom9(b []byte) uint64 {
- var r uint64
+func bloom9(b []byte) *big.Int {
+ r := new(big.Int)
for _, i := range []int{0, 2, 4} {
- r |= 1 << (uint64(b[i+1]) + 256*(uint64(b[i])&1))
+ t := big.NewInt(1)
+
+ //r |= 1 << (uint64(b[i+1]) + 256*(uint64(b[i])&1))
+ r.Or(r, t.Rsh(t, uint(b[i+1])+256*(uint(b[i])&1)))
}
return r