aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmd/mist/bindings.go2
-rw-r--r--cmd/mist/debugger.go4
-rw-r--r--cmd/mist/gui.go8
-rw-r--r--cmd/mist/ui_lib.go2
-rw-r--r--core/block_manager.go10
-rw-r--r--core/chain_manager.go13
-rw-r--r--core/transaction_pool.go2
-rw-r--r--javascript/javascript_runtime.go2
-rw-r--r--miner/miner.go2
-rw-r--r--xeth/pipe.go12
-rw-r--r--xeth/world.go2
11 files changed, 31 insertions, 28 deletions
diff --git a/cmd/mist/bindings.go b/cmd/mist/bindings.go
index 6dbcc3f1d..6d2342c87 100644
--- a/cmd/mist/bindings.go
+++ b/cmd/mist/bindings.go
@@ -103,7 +103,7 @@ func (self *Gui) DumpState(hash, path string) {
var stateDump []byte
if len(hash) == 0 {
- stateDump = self.eth.BlockManager().CurrentState().Dump()
+ stateDump = self.eth.ChainManager().State().Dump()
} else {
var block *types.Block
if hash[0] == '#' {
diff --git a/cmd/mist/debugger.go b/cmd/mist/debugger.go
index ca3ff5af2..d7c584eab 100644
--- a/cmd/mist/debugger.go
+++ b/cmd/mist/debugger.go
@@ -141,8 +141,8 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, data
keyPair = self.lib.eth.KeyManager().KeyPair()
)
- statedb := self.lib.eth.BlockManager().TransState()
- account := self.lib.eth.BlockManager().TransState().GetAccount(keyPair.Address())
+ statedb := self.lib.eth.ChainManager().TransState()
+ account := self.lib.eth.ChainManager().TransState().GetAccount(keyPair.Address())
contract := statedb.NewStateObject([]byte{0})
contract.SetCode(script)
contract.SetBalance(value)
diff --git a/cmd/mist/gui.go b/cmd/mist/gui.go
index 0b03cdc1b..fe066e994 100644
--- a/cmd/mist/gui.go
+++ b/cmd/mist/gui.go
@@ -401,7 +401,7 @@ func (gui *Gui) update() {
generalUpdateTicker := time.NewTicker(500 * time.Millisecond)
statsUpdateTicker := time.NewTicker(5 * time.Second)
- state := gui.eth.BlockManager().TransState()
+ state := gui.eth.ChainManager().TransState()
gui.win.Root().Call("setWalletValue", fmt.Sprintf("%v", ethutil.CurrencyToString(state.GetAccount(gui.address()).Balance())))
@@ -428,14 +428,14 @@ func (gui *Gui) update() {
case core.NewBlockEvent:
gui.processBlock(ev.Block, false)
if bytes.Compare(ev.Block.Coinbase, gui.address()) == 0 {
- gui.setWalletValue(gui.eth.BlockManager().CurrentState().GetAccount(gui.address()).Balance(), nil)
+ gui.setWalletValue(gui.eth.ChainManager().State().GetBalance(gui.address()), nil)
}
case core.TxPreEvent:
tx := ev.Tx
- tstate := gui.eth.BlockManager().TransState()
- cstate := gui.eth.BlockManager().CurrentState()
+ tstate := gui.eth.ChainManager().TransState()
+ cstate := gui.eth.ChainManager().State()
taccount := tstate.GetAccount(gui.address())
caccount := cstate.GetAccount(gui.address())
diff --git a/cmd/mist/ui_lib.go b/cmd/mist/ui_lib.go
index 2b5e56646..fdbde50fd 100644
--- a/cmd/mist/ui_lib.go
+++ b/cmd/mist/ui_lib.go
@@ -200,7 +200,7 @@ func (ui *UiLib) AssetPath(p string) string {
func (self *UiLib) StartDbWithContractAndData(contractHash, data string) {
dbWindow := NewDebuggerWindow(self)
- object := self.eth.BlockManager().CurrentState().GetStateObject(ethutil.Hex2Bytes(contractHash))
+ object := self.eth.ChainManager().State().GetStateObject(ethutil.Hex2Bytes(contractHash))
if len(object.Code) > 0 {
dbWindow.SetCode("0x" + ethutil.Bytes2Hex(object.Code))
}
diff --git a/core/block_manager.go b/core/block_manager.go
index 80b2542b5..7227c6f95 100644
--- a/core/block_manager.go
+++ b/core/block_manager.go
@@ -84,20 +84,10 @@ func NewBlockManager(ethereum EthManager) *BlockManager {
eth: ethereum,
bc: ethereum.ChainManager(),
}
- sm.transState = ethereum.ChainManager().CurrentBlock.State().Copy()
- sm.miningState = ethereum.ChainManager().CurrentBlock.State().Copy()
return sm
}
-func (sm *BlockManager) CurrentState() *state.StateDB {
- return sm.eth.ChainManager().CurrentBlock.State()
-}
-
-func (sm *BlockManager) TransState() *state.StateDB {
- return sm.transState
-}
-
func (sm *BlockManager) TransitionState(statedb *state.StateDB, parent, block *types.Block) (receipts types.Receipts, err error) {
coinbase := statedb.GetOrNewStateObject(block.Coinbase)
coinbase.SetGasPool(block.CalcGasLimit(parent))
diff --git a/core/chain_manager.go b/core/chain_manager.go
index 150139def..0322edaa5 100644
--- a/core/chain_manager.go
+++ b/core/chain_manager.go
@@ -8,6 +8,7 @@ import (
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger"
+ "github.com/ethereum/go-ethereum/state"
)
var chainlogger = logger.NewLogger("CHAIN")
@@ -55,6 +56,8 @@ type ChainManager struct {
CurrentBlock *types.Block
LastBlockHash []byte
+
+ transState *state.StateDB
}
func NewChainManager(mux *event.TypeMux) *ChainManager {
@@ -64,6 +67,8 @@ func NewChainManager(mux *event.TypeMux) *ChainManager {
bc.setLastBlock()
+ bc.transState = bc.State().Copy()
+
return bc
}
@@ -71,6 +76,14 @@ func (self *ChainManager) SetProcessor(proc types.BlockProcessor) {
self.processor = proc
}
+func (self *ChainManager) State() *state.StateDB {
+ return self.CurrentBlock.State()
+}
+
+func (self *ChainManager) TransState() *state.StateDB {
+ return self.transState
+}
+
func (bc *ChainManager) setLastBlock() {
data, _ := ethutil.Config.Db.Get([]byte("LastBlock"))
if len(data) != 0 {
diff --git a/core/transaction_pool.go b/core/transaction_pool.go
index 1d1f478e4..7166d35e8 100644
--- a/core/transaction_pool.go
+++ b/core/transaction_pool.go
@@ -116,7 +116,7 @@ func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error {
}
// Get the sender
- sender := pool.Ethereum.BlockManager().CurrentState().GetAccount(tx.Sender())
+ sender := pool.Ethereum.ChainManager().State().GetAccount(tx.Sender())
totAmount := new(big.Int).Set(tx.Value)
// Make sure there's enough in the sender's account. Having insufficient
diff --git a/javascript/javascript_runtime.go b/javascript/javascript_runtime.go
index a5b929a34..84d61d405 100644
--- a/javascript/javascript_runtime.go
+++ b/javascript/javascript_runtime.go
@@ -150,7 +150,7 @@ func (self *JSRE) dump(call otto.FunctionCall) otto.Value {
state = block.State()
} else {
- state = self.ethereum.BlockManager().CurrentState()
+ state = self.ethereum.ChainManager().State()
}
v, _ := self.Vm.ToValue(state.Dump())
diff --git a/miner/miner.go b/miner/miner.go
index 82a92cc20..dc69dddc0 100644
--- a/miner/miner.go
+++ b/miner/miner.go
@@ -232,7 +232,7 @@ func (self *Miner) finiliseTxs() types.Transactions {
actualSize := len(self.localTxs) // See copy below
txs := make(types.Transactions, actualSize+self.eth.TxPool().Size())
- state := self.eth.BlockManager().TransState()
+ state := self.eth.ChainManager().TransState()
// XXX This has to change. Coinbase is, for new, same as key.
key := self.eth.KeyManager()
for i, ltx := range self.localTxs {
diff --git a/xeth/pipe.go b/xeth/pipe.go
index 2ca8134ce..a8d8ed999 100644
--- a/xeth/pipe.go
+++ b/xeth/pipe.go
@@ -22,7 +22,7 @@ type VmVars struct {
type XEth struct {
obj core.EthManager
blockManager *core.BlockManager
- blockChain *core.ChainManager
+ chainManager *core.ChainManager
world *World
Vm VmVars
@@ -32,7 +32,7 @@ func New(obj core.EthManager) *XEth {
pipe := &XEth{
obj: obj,
blockManager: obj.BlockManager(),
- blockChain: obj.ChainManager(),
+ chainManager: obj.ChainManager(),
}
pipe.world = NewWorld(pipe)
@@ -51,7 +51,7 @@ func (self *XEth) Nonce(addr []byte) uint64 {
}
func (self *XEth) Block(hash []byte) *types.Block {
- return self.blockChain.GetBlock(hash)
+ return self.chainManager.GetBlock(hash)
}
func (self *XEth) Storage(addr, storageAddr []byte) *ethutil.Value {
@@ -82,7 +82,7 @@ func (self *XEth) Execute(addr []byte, data []byte, value, gas, price *ethutil.V
func (self *XEth) ExecuteObject(object *Object, data []byte, value, gas, price *ethutil.Value) ([]byte, error) {
var (
initiator = state.NewStateObject(self.obj.KeyManager().KeyPair().Address())
- block = self.blockChain.CurrentBlock
+ block = self.chainManager.CurrentBlock
)
self.Vm.State = self.World().State().Copy()
@@ -131,14 +131,14 @@ func (self *XEth) Transact(key *crypto.KeyPair, to []byte, value, gas, price *et
tx = types.NewTransactionMessage(hash, value.BigInt(), gas.BigInt(), price.BigInt(), data)
}
- state := self.blockManager.TransState()
+ state := self.chainManager.TransState()
nonce := state.GetNonce(key.Address())
tx.Nonce = nonce
tx.Sign(key.PrivateKey)
// Do some pre processing for our "pre" events and hooks
- block := self.blockChain.NewBlock(key.Address())
+ block := self.chainManager.NewBlock(key.Address())
coinbase := state.GetStateObject(key.Address())
coinbase.SetGasPool(block.GasLimit)
self.blockManager.ApplyTransactions(coinbase, state, block, types.Transactions{tx}, true)
diff --git a/xeth/world.go b/xeth/world.go
index c5c20c224..956ef1e15 100644
--- a/xeth/world.go
+++ b/xeth/world.go
@@ -23,7 +23,7 @@ func (self *XEth) World() *World {
}
func (self *World) State() *state.StateDB {
- return self.pipe.blockManager.CurrentState()
+ return self.pipe.chainManager.State()
}
func (self *World) Get(addr []byte) *Object {