aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain/state_manager.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-07-25 16:43:35 +0800
committerobscuren <geffobscura@gmail.com>2014-07-25 16:43:35 +0800
commitd761af84c83ae8d9d723e6766abb7950ff59cdf3 (patch)
tree6fe0805649ddf38b2b90e77c5fb2000a4bdab536 /ethchain/state_manager.go
parent06ec80f39495bdd92878468cf862f52e9748f1ca (diff)
parent54f9ea14e197ad805f24592153f1b9e69f3bc5c3 (diff)
downloaddexon-d761af84c83ae8d9d723e6766abb7950ff59cdf3.tar.gz
dexon-d761af84c83ae8d9d723e6766abb7950ff59cdf3.tar.zst
dexon-d761af84c83ae8d9d723e6766abb7950ff59cdf3.zip
Merge branch 'release/0.6.0'
Diffstat (limited to 'ethchain/state_manager.go')
-rw-r--r--ethchain/state_manager.go37
1 files changed, 17 insertions, 20 deletions
diff --git a/ethchain/state_manager.go b/ethchain/state_manager.go
index 6a6c67492..9408cf331 100644
--- a/ethchain/state_manager.go
+++ b/ethchain/state_manager.go
@@ -6,7 +6,7 @@ import (
"fmt"
"github.com/ethereum/eth-go/ethcrypto"
"github.com/ethereum/eth-go/ethlog"
- _ "github.com/ethereum/eth-go/ethtrie"
+ "github.com/ethereum/eth-go/ethstate"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethwire"
"math/big"
@@ -50,8 +50,6 @@ type StateManager struct {
mutex sync.Mutex
// Canonical block chain
bc *BlockChain
- // Stack for processing contracts
- stack *Stack
// non-persistent key/value memory storage
mem map[string]*big.Int
// Proof of work used for validating
@@ -62,10 +60,10 @@ type StateManager struct {
// Transiently state. The trans state isn't ever saved, validated and
// it could be used for setting account nonces without effecting
// the main states.
- transState *State
+ transState *ethstate.State
// Mining state. The mining state is used purely and solely by the mining
// operation.
- miningState *State
+ miningState *ethstate.State
// The last attempted block is mainly used for debugging purposes
// This does not have to be a valid block and will be set during
@@ -75,7 +73,6 @@ type StateManager struct {
func NewStateManager(ethereum EthManager) *StateManager {
sm := &StateManager{
- stack: NewStack(),
mem: make(map[string]*big.Int),
Pow: &EasyPow{},
Ethereum: ethereum,
@@ -87,19 +84,19 @@ func NewStateManager(ethereum EthManager) *StateManager {
return sm
}
-func (sm *StateManager) CurrentState() *State {
+func (sm *StateManager) CurrentState() *ethstate.State {
return sm.Ethereum.BlockChain().CurrentBlock.State()
}
-func (sm *StateManager) TransState() *State {
+func (sm *StateManager) TransState() *ethstate.State {
return sm.transState
}
-func (sm *StateManager) MiningState() *State {
+func (sm *StateManager) MiningState() *ethstate.State {
return sm.miningState
}
-func (sm *StateManager) NewMiningState() *State {
+func (sm *StateManager) NewMiningState() *ethstate.State {
sm.miningState = sm.Ethereum.BlockChain().CurrentBlock.State().Copy()
return sm.miningState
@@ -109,7 +106,7 @@ func (sm *StateManager) BlockChain() *BlockChain {
return sm.bc
}
-func (self *StateManager) ProcessTransactions(coinbase *StateObject, state *State, block, parent *Block, txs Transactions) (Receipts, Transactions, Transactions, error) {
+func (self *StateManager) ProcessTransactions(coinbase *ethstate.StateObject, state *ethstate.State, block, parent *Block, txs Transactions) (Receipts, Transactions, Transactions, error) {
var (
receipts Receipts
handled, unhandled Transactions
@@ -123,9 +120,9 @@ done:
cb := state.GetStateObject(coinbase.Address())
st := NewStateTransition(cb, tx, state, block)
- //fmt.Printf("#%d\n", i+1)
err = st.TransitionState()
if err != nil {
+ statelogger.Infoln(err)
switch {
case IsNonceErr(err):
err = nil // ignore error
@@ -225,7 +222,7 @@ func (sm *StateManager) Process(block *Block, dontReact bool) (err error) {
}
if !block.State().Cmp(state) {
- err = fmt.Errorf("Invalid merkle root.\nrec: %x\nis: %x", block.State().trie.Root, state.trie.Root)
+ err = fmt.Errorf("Invalid merkle root.\nrec: %x\nis: %x", block.State().Trie.Root, state.Trie.Root)
return
}
@@ -242,7 +239,7 @@ func (sm *StateManager) Process(block *Block, dontReact bool) (err error) {
if dontReact == false {
sm.Ethereum.Reactor().Post("newBlock", block)
- state.manifest.Reset()
+ state.Manifest().Reset()
}
sm.Ethereum.Broadcast(ethwire.MsgBlockTy, []interface{}{block.Value().Val})
@@ -255,7 +252,7 @@ func (sm *StateManager) Process(block *Block, dontReact bool) (err error) {
return nil
}
-func (sm *StateManager) ApplyDiff(state *State, parent, block *Block) (receipts Receipts, err error) {
+func (sm *StateManager) ApplyDiff(state *ethstate.State, parent, block *Block) (receipts Receipts, err error) {
coinbase := state.GetOrNewStateObject(block.Coinbase)
coinbase.SetGasPool(block.CalcGasLimit(parent))
@@ -340,7 +337,7 @@ func CalculateUncleReward(block *Block) *big.Int {
return UncleReward
}
-func (sm *StateManager) AccumelateRewards(state *State, block *Block) error {
+func (sm *StateManager) AccumelateRewards(state *ethstate.State, block *Block) error {
// Get the account associated with the coinbase
account := state.GetAccount(block.Coinbase)
// Reward amount of ether to the coinbase address
@@ -364,14 +361,14 @@ func (sm *StateManager) Stop() {
sm.bc.Stop()
}
-func (sm *StateManager) notifyChanges(state *State) {
- for addr, stateObject := range state.manifest.objectChanges {
+func (sm *StateManager) notifyChanges(state *ethstate.State) {
+ for addr, stateObject := range state.Manifest().ObjectChanges {
sm.Ethereum.Reactor().Post("object:"+addr, stateObject)
}
- for stateObjectAddr, mappedObjects := range state.manifest.storageChanges {
+ for stateObjectAddr, mappedObjects := range state.Manifest().StorageChanges {
for addr, value := range mappedObjects {
- sm.Ethereum.Reactor().Post("storage:"+stateObjectAddr+":"+addr, &StorageState{[]byte(stateObjectAddr), []byte(addr), value})
+ sm.Ethereum.Reactor().Post("storage:"+stateObjectAddr+":"+addr, &ethstate.StorageState{[]byte(stateObjectAddr), []byte(addr), value})
}
}
}