aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-12-11 02:59:12 +0800
committerobscuren <geffobscura@gmail.com>2014-12-11 02:59:12 +0800
commit5553e5aaed5c3f4e303b7d6671d2c92a45aa487e (patch)
treefc4f9c7a088d0af0e3eec76258df89c3e9968ba4 /core
parentaf6afbaa56efa15abe6a03665c6674b0e2f591c8 (diff)
downloaddexon-5553e5aaed5c3f4e303b7d6671d2c92a45aa487e.tar
dexon-5553e5aaed5c3f4e303b7d6671d2c92a45aa487e.tar.gz
dexon-5553e5aaed5c3f4e303b7d6671d2c92a45aa487e.tar.bz2
dexon-5553e5aaed5c3f4e303b7d6671d2c92a45aa487e.tar.lz
dexon-5553e5aaed5c3f4e303b7d6671d2c92a45aa487e.tar.xz
dexon-5553e5aaed5c3f4e303b7d6671d2c92a45aa487e.tar.zst
dexon-5553e5aaed5c3f4e303b7d6671d2c92a45aa487e.zip
states moved to chain
Diffstat (limited to 'core')
-rw-r--r--core/block_manager.go10
-rw-r--r--core/chain_manager.go13
-rw-r--r--core/transaction_pool.go2
3 files changed, 14 insertions, 11 deletions
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