diff options
author | obscuren <geffobscura@gmail.com> | 2014-10-29 17:34:40 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-10-29 17:34:40 +0800 |
commit | fb4113dab4df8480c77bdcb707fa6b5408755b79 (patch) | |
tree | b369bb26e7b96826120fb08ff61739326add0e92 /ethchain/bloom9.go | |
parent | 665a44646e9453e37c8a73bdd2c94ba7dc1e7c0a (diff) | |
download | dexon-fb4113dab4df8480c77bdcb707fa6b5408755b79.tar dexon-fb4113dab4df8480c77bdcb707fa6b5408755b79.tar.gz dexon-fb4113dab4df8480c77bdcb707fa6b5408755b79.tar.bz2 dexon-fb4113dab4df8480c77bdcb707fa6b5408755b79.tar.lz dexon-fb4113dab4df8480c77bdcb707fa6b5408755b79.tar.xz dexon-fb4113dab4df8480c77bdcb707fa6b5408755b79.tar.zst dexon-fb4113dab4df8480c77bdcb707fa6b5408755b79.zip |
PoC 7 updates
* Bloom
* Block restructure
* Receipts
Diffstat (limited to 'ethchain/bloom9.go')
-rw-r--r-- | ethchain/bloom9.go | 31 |
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 |