aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/types/block.go6
-rw-r--r--core/types/bloom9.go6
-rw-r--r--core/types/receipt.go36
3 files changed, 24 insertions, 24 deletions
diff --git a/core/types/block.go b/core/types/block.go
index 80fc238aa..aca23aa04 100644
--- a/core/types/block.go
+++ b/core/types/block.go
@@ -106,14 +106,14 @@ func NewBlock(parentHash common.Hash, coinbase common.Address, root common.Hash,
GasUsed: new(big.Int),
GasLimit: new(big.Int),
}
- header.setNonce(nonce)
+ header.SetNonce(nonce)
block := &Block{header: header, Reward: new(big.Int)}
return block
}
-func (self *Header) setNonce(nonce uint64) {
+func (self *Header) SetNonce(nonce uint64) {
binary.BigEndian.PutUint64(self.Nonce[:], nonce)
}
@@ -203,7 +203,7 @@ func (self *Block) Nonce() uint64 {
return binary.BigEndian.Uint64(self.header.Nonce[:])
}
func (self *Block) SetNonce(nonce uint64) {
- self.header.setNonce(nonce)
+ self.header.SetNonce(nonce)
}
func (self *Block) Bloom() Bloom { return self.header.Bloom }
diff --git a/core/types/bloom9.go b/core/types/bloom9.go
index e5b5e395f..b3cab86a0 100644
--- a/core/types/bloom9.go
+++ b/core/types/bloom9.go
@@ -20,15 +20,15 @@ func CreateBloom(receipts Receipts) Bloom {
func LogsBloom(logs state.Logs) *big.Int {
bin := new(big.Int)
for _, log := range logs {
- data := make([][]byte, len(log.Topics())+1)
- data[0] = log.Address()
+ data := make([]common.Hash, len(log.Topics())+1)
+ data[0] = log.Address().Hash()
for i, topic := range log.Topics() {
data[i+1] = topic
}
for _, b := range data {
- bin.Or(bin, common.BigD(bloom9(crypto.Sha3(b)).Bytes()))
+ bin.Or(bin, common.BigD(bloom9(crypto.Sha3(b[:])).Bytes()))
}
}
diff --git a/core/types/receipt.go b/core/types/receipt.go
index be14d0e0e..d0cb41e25 100644
--- a/core/types/receipt.go
+++ b/core/types/receipt.go
@@ -3,9 +3,11 @@ package types
import (
"bytes"
"fmt"
+ "io"
"math/big"
"github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/state"
)
@@ -20,34 +22,26 @@ func NewReceipt(root []byte, cumalativeGasUsed *big.Int) *Receipt {
return &Receipt{PostState: common.CopyBytes(root), CumulativeGasUsed: new(big.Int).Set(cumalativeGasUsed)}
}
-func NewRecieptFromValue(val *common.Value) *Receipt {
- r := &Receipt{}
- r.RlpValueDecode(val)
-
- return r
-}
-
func (self *Receipt) SetLogs(logs state.Logs) {
self.logs = logs
}
-func (self *Receipt) RlpValueDecode(decoder *common.Value) {
- self.PostState = decoder.Get(0).Bytes()
- self.CumulativeGasUsed = decoder.Get(1).BigInt()
- self.Bloom = decoder.Get(2).Bytes()
-
- it := decoder.Get(3).NewIterator()
- for it.Next() {
- self.logs = append(self.logs, state.NewLogFromValue(it.Value()))
- }
+func (self *Receipt) EncodeRLP(w io.Writer) error {
+ return rlp.Encode(w, []interface{}{self.PostState, self.CumulativeGasUsed, self.Bloom, self.logs})
}
+/*
func (self *Receipt) RlpData() interface{} {
return []interface{}{self.PostState, self.CumulativeGasUsed, self.Bloom, self.logs.RlpData()}
}
+*/
func (self *Receipt) RlpEncode() []byte {
- return common.Encode(self.RlpData())
+ bytes, err := rlp.EncodeToBytes(self)
+ if err != nil {
+ fmt.Println("TMP -- RECEIPT ENCODE ERROR", err)
+ }
+ return bytes
}
func (self *Receipt) Cmp(other *Receipt) bool {
@@ -64,6 +58,7 @@ func (self *Receipt) String() string {
type Receipts []*Receipt
+/*
func (self Receipts) RlpData() interface{} {
data := make([]interface{}, len(self))
for i, receipt := range self {
@@ -72,9 +67,14 @@ func (self Receipts) RlpData() interface{} {
return data
}
+*/
func (self Receipts) RlpEncode() []byte {
- return common.Encode(self.RlpData())
+ bytes, err := rlp.EncodeToBytes(self)
+ if err != nil {
+ fmt.Println("TMP -- RECEIPTS ENCODE ERROR", err)
+ }
+ return bytes
}
func (self Receipts) Len() int { return len(self) }