diff options
author | obscuren <geffobscura@gmail.com> | 2014-03-03 18:03:16 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-03-03 18:03:16 +0800 |
commit | bfed1c7cac98e135ba176c03bd7b4fe51c0dc932 (patch) | |
tree | 2cfd6e9c715d43b9142bf0513c8866f642b84aa2 /ethchain/block.go | |
parent | d2bc57cd34fe4da3ecec3ff95bc4ef9e74589e5d (diff) | |
download | go-tangerine-bfed1c7cac98e135ba176c03bd7b4fe51c0dc932.tar go-tangerine-bfed1c7cac98e135ba176c03bd7b4fe51c0dc932.tar.gz go-tangerine-bfed1c7cac98e135ba176c03bd7b4fe51c0dc932.tar.bz2 go-tangerine-bfed1c7cac98e135ba176c03bd7b4fe51c0dc932.tar.lz go-tangerine-bfed1c7cac98e135ba176c03bd7b4fe51c0dc932.tar.xz go-tangerine-bfed1c7cac98e135ba176c03bd7b4fe51c0dc932.tar.zst go-tangerine-bfed1c7cac98e135ba176c03bd7b4fe51c0dc932.zip |
Trie's are no longer referenced directly but through State instead
Diffstat (limited to 'ethchain/block.go')
-rw-r--r-- | ethchain/block.go | 65 |
1 files changed, 2 insertions, 63 deletions
diff --git a/ethchain/block.go b/ethchain/block.go index 8de57cced..b5739102c 100644 --- a/ethchain/block.go +++ b/ethchain/block.go @@ -126,54 +126,6 @@ func (block *Block) Transactions() []*Transaction { return block.transactions } -/* -func (block *Block) GetContract(addr []byte) *Contract { - data := block.state.Get(string(addr)) - if data == "" { - return nil - } - - value := ethutil.NewValueFromBytes([]byte(data)) - if value.Len() == 2 { - return nil - } - - contract := &Contract{} - contract.RlpDecode([]byte(data)) - - cachedState := block.contractStates[string(addr)] - if cachedState != nil { - contract.state = cachedState - } else { - block.contractStates[string(addr)] = contract.state - } - - return contract -} -func (block *Block) UpdateContract(addr []byte, contract *Contract) { - // Make sure the state is synced - //contract.State().Sync() - - block.state.trie.Update(string(addr), string(contract.RlpEncode())) -} - -func (block *Block) GetAddr(addr []byte) *Address { - var address *Address - - data := block.state.trie.Get(string(addr)) - if data == "" { - address = NewAddress(big.NewInt(0)) - } else { - address = NewAddressFromData([]byte(data)) - } - - return address -} -func (block *Block) UpdateAddr(addr []byte, address *Address) { - block.state.trie.Update(string(addr), string(address.RlpEncode())) -} -*/ - func (block *Block) PayFee(addr []byte, fee *big.Int) bool { contract := block.state.GetContract(addr) // If we can't pay the fee return @@ -210,23 +162,10 @@ func (block *Block) BlockInfo() BlockInfo { // Sync the block's state and contract respectively func (block *Block) Sync() { - /* - // Sync all contracts currently in cache - for _, val := range block.contractStates { - val.Sync() - } - */ - // Sync the block state itself - block.state.trie.Sync() + block.state.Sync() } func (block *Block) Undo() { - /* - // Sync all contracts currently in cache - for _, val := range block.contractStates { - val.Undo() - } - */ // Sync the block state itself block.state.Reset() } @@ -234,7 +173,7 @@ func (block *Block) Undo() { func (block *Block) MakeContract(tx *Transaction) { contract := MakeContract(tx, block.state) if contract != nil { - block.contractStates[string(tx.Hash()[12:])] = contract.state + block.state.states[string(tx.Hash()[12:])] = contract.state } } |