diff options
Diffstat (limited to 'ethchain/block.go')
-rw-r--r-- | ethchain/block.go | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/ethchain/block.go b/ethchain/block.go index 447d55f99..437525e35 100644 --- a/ethchain/block.go +++ b/ethchain/block.go @@ -4,6 +4,7 @@ import ( "bytes" "fmt" "github.com/ethereum/eth-go/ethcrypto" + "github.com/ethereum/eth-go/ethstate" "github.com/ethereum/eth-go/ethtrie" "github.com/ethereum/eth-go/ethutil" "math/big" @@ -39,7 +40,7 @@ type Block struct { Coinbase []byte // Block Trie state //state *ethutil.Trie - state *State + state *ethstate.State // Difficulty for the current block Difficulty *big.Int // Creation time @@ -104,7 +105,7 @@ func CreateBlock(root interface{}, } block.SetUncles([]*Block{}) - block.state = NewState(ethtrie.NewTrie(ethutil.Config.Db, root)) + block.state = ethstate.NewState(ethtrie.NewTrie(ethutil.Config.Db, root)) return block } @@ -116,12 +117,12 @@ func (block *Block) Hash() []byte { func (block *Block) HashNoNonce() []byte { return ethcrypto.Sha3Bin(ethutil.Encode([]interface{}{block.PrevHash, - block.UncleSha, block.Coinbase, block.state.trie.Root, + block.UncleSha, block.Coinbase, block.state.Trie.Root, block.TxSha, block.Difficulty, block.Number, block.MinGasPrice, block.GasLimit, block.GasUsed, block.Time, block.Extra})) } -func (block *Block) State() *State { +func (block *Block) State() *ethstate.State { return block.state } @@ -140,17 +141,17 @@ func (block *Block) PayFee(addr []byte, fee *big.Int) bool { base := new(big.Int) contract.Amount = base.Sub(contract.Amount, fee) - block.state.trie.Update(string(addr), string(contract.RlpEncode())) + block.state.Trie.Update(string(addr), string(contract.RlpEncode())) - data := block.state.trie.Get(string(block.Coinbase)) + data := block.state.Trie.Get(string(block.Coinbase)) // Get the ether (Coinbase) and add the fee (gief fee to miner) - account := NewStateObjectFromBytes(block.Coinbase, []byte(data)) + account := ethstate.NewStateObjectFromBytes(block.Coinbase, []byte(data)) base = new(big.Int) account.Amount = base.Add(account.Amount, fee) - //block.state.trie.Update(string(block.Coinbase), string(ether.RlpEncode())) + //block.state.Trie.Update(string(block.Coinbase), string(ether.RlpEncode())) block.state.UpdateStateObject(account) return true @@ -312,7 +313,7 @@ func (block *Block) RlpValueDecode(decoder *ethutil.Value) { block.PrevHash = header.Get(0).Bytes() block.UncleSha = header.Get(1).Bytes() block.Coinbase = header.Get(2).Bytes() - block.state = NewState(ethtrie.NewTrie(ethutil.Config.Db, header.Get(3).Val)) + block.state = ethstate.NewState(ethtrie.NewTrie(ethutil.Config.Db, header.Get(3).Val)) block.TxSha = header.Get(4).Bytes() block.Difficulty = header.Get(5).BigInt() block.Number = header.Get(6).BigInt() @@ -354,7 +355,7 @@ func NewUncleBlockFromValue(header *ethutil.Value) *Block { block.PrevHash = header.Get(0).Bytes() block.UncleSha = header.Get(1).Bytes() block.Coinbase = header.Get(2).Bytes() - block.state = NewState(ethtrie.NewTrie(ethutil.Config.Db, header.Get(3).Val)) + block.state = ethstate.NewState(ethtrie.NewTrie(ethutil.Config.Db, header.Get(3).Val)) block.TxSha = header.Get(4).Bytes() block.Difficulty = header.Get(5).BigInt() block.Number = header.Get(6).BigInt() @@ -369,7 +370,7 @@ func NewUncleBlockFromValue(header *ethutil.Value) *Block { } func (block *Block) GetRoot() interface{} { - return block.state.trie.Root + return block.state.Trie.Root } func (self *Block) Receipts() []*Receipt { @@ -385,7 +386,7 @@ func (block *Block) header() []interface{} { // Coinbase address block.Coinbase, // root state - block.state.trie.Root, + block.state.Trie.Root, // Sha of tx block.TxSha, // Current block Difficulty @@ -429,7 +430,7 @@ func (block *Block) String() string { block.PrevHash, block.UncleSha, block.Coinbase, - block.state.trie.Root, + block.state.Trie.Root, block.TxSha, block.Difficulty, block.Number, |