Renamed State => StateDB
This commit is contained in:
@ -62,10 +62,10 @@ type BlockManager 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.State
|
||||
transState *state.StateDB
|
||||
// Mining state. The mining state is used purely and solely by the mining
|
||||
// operation.
|
||||
miningState *state.State
|
||||
miningState *state.StateDB
|
||||
|
||||
// The last attempted block is mainly used for debugging purposes
|
||||
// This does not have to be a valid block and will be set during
|
||||
@ -96,19 +96,19 @@ func (self *BlockManager) Stop() {
|
||||
statelogger.Debugln("Stopping state manager")
|
||||
}
|
||||
|
||||
func (sm *BlockManager) CurrentState() *state.State {
|
||||
func (sm *BlockManager) CurrentState() *state.StateDB {
|
||||
return sm.eth.ChainManager().CurrentBlock.State()
|
||||
}
|
||||
|
||||
func (sm *BlockManager) TransState() *state.State {
|
||||
func (sm *BlockManager) TransState() *state.StateDB {
|
||||
return sm.transState
|
||||
}
|
||||
|
||||
func (sm *BlockManager) MiningState() *state.State {
|
||||
func (sm *BlockManager) MiningState() *state.StateDB {
|
||||
return sm.miningState
|
||||
}
|
||||
|
||||
func (sm *BlockManager) NewMiningState() *state.State {
|
||||
func (sm *BlockManager) NewMiningState() *state.StateDB {
|
||||
sm.miningState = sm.eth.ChainManager().CurrentBlock.State().Copy()
|
||||
|
||||
return sm.miningState
|
||||
@ -118,7 +118,7 @@ func (sm *BlockManager) ChainManager() *ChainManager {
|
||||
return sm.bc
|
||||
}
|
||||
|
||||
func (sm *BlockManager) TransitionState(statedb *state.State, parent, block *types.Block) (receipts types.Receipts, err error) {
|
||||
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))
|
||||
|
||||
@ -131,7 +131,7 @@ func (sm *BlockManager) TransitionState(statedb *state.State, parent, block *typ
|
||||
return receipts, nil
|
||||
}
|
||||
|
||||
func (self *BlockManager) ProcessTransactions(coinbase *state.StateObject, state *state.State, block, parent *types.Block, txs types.Transactions) (types.Receipts, types.Transactions, types.Transactions, types.Transactions, error) {
|
||||
func (self *BlockManager) ProcessTransactions(coinbase *state.StateObject, state *state.StateDB, block, parent *types.Block, txs types.Transactions) (types.Receipts, types.Transactions, types.Transactions, types.Transactions, error) {
|
||||
var (
|
||||
receipts types.Receipts
|
||||
handled, unhandled types.Transactions
|
||||
@ -342,7 +342,7 @@ func (sm *BlockManager) ValidateBlock(block, parent *types.Block) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sm *BlockManager) AccumelateRewards(statedb *state.State, block, parent *types.Block) error {
|
||||
func (sm *BlockManager) AccumelateRewards(statedb *state.StateDB, block, parent *types.Block) error {
|
||||
reward := new(big.Int).Set(BlockReward)
|
||||
|
||||
knownUncles := ethutil.Set(parent.Uncles)
|
||||
|
@ -31,13 +31,13 @@ type StateTransition struct {
|
||||
gas, gasPrice *big.Int
|
||||
value *big.Int
|
||||
data []byte
|
||||
state *state.State
|
||||
state *state.StateDB
|
||||
block *types.Block
|
||||
|
||||
cb, rec, sen *state.StateObject
|
||||
}
|
||||
|
||||
func NewStateTransition(coinbase *state.StateObject, tx *types.Transaction, state *state.State, block *types.Block) *StateTransition {
|
||||
func NewStateTransition(coinbase *state.StateObject, tx *types.Transaction, state *state.StateDB, block *types.Block) *StateTransition {
|
||||
return &StateTransition{coinbase.Address(), tx.Recipient, tx, new(big.Int), new(big.Int).Set(tx.GasPrice), tx.Value, tx.Data, state, block, coinbase, nil, nil}
|
||||
}
|
||||
|
||||
@ -188,7 +188,7 @@ func (self *StateTransition) TransitionState() (err error) {
|
||||
}
|
||||
|
||||
// Converts an transaction in to a state object
|
||||
func MakeContract(tx *types.Transaction, state *state.State) *state.StateObject {
|
||||
func MakeContract(tx *types.Transaction, state *state.StateDB) *state.StateObject {
|
||||
addr := tx.CreationAddress(state)
|
||||
|
||||
contract := state.GetOrNewStateObject(addr)
|
||||
|
@ -186,7 +186,7 @@ func (pool *TxPool) CurrentTransactions() []*types.Transaction {
|
||||
return txList
|
||||
}
|
||||
|
||||
func (pool *TxPool) RemoveInvalid(state *state.State) {
|
||||
func (pool *TxPool) RemoveInvalid(state *state.StateDB) {
|
||||
pool.mutex.Lock()
|
||||
defer pool.mutex.Unlock()
|
||||
|
||||
|
@ -77,7 +77,7 @@ type Block struct {
|
||||
Coinbase []byte
|
||||
// Block Trie state
|
||||
//state *ethutil.Trie
|
||||
state *state.State
|
||||
state *state.StateDB
|
||||
// Difficulty for the current block
|
||||
Difficulty *big.Int
|
||||
// Creation time
|
||||
@ -151,7 +151,7 @@ func (block *Block) HashNoNonce() []byte {
|
||||
return crypto.Sha3(ethutil.Encode(block.miningHeader()))
|
||||
}
|
||||
|
||||
func (block *Block) State() *state.State {
|
||||
func (block *Block) State() *state.StateDB {
|
||||
return block.state
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ func (tx *Transaction) IsContract() bool {
|
||||
return tx.CreatesContract()
|
||||
}
|
||||
|
||||
func (tx *Transaction) CreationAddress(state *state.State) []byte {
|
||||
func (tx *Transaction) CreationAddress(state *state.StateDB) []byte {
|
||||
// Generate a new address
|
||||
return crypto.Sha3(ethutil.NewValue([]interface{}{tx.Sender(), tx.Nonce}).Encode())[12:]
|
||||
}
|
||||
|
@ -9,13 +9,13 @@ import (
|
||||
)
|
||||
|
||||
type VMEnv struct {
|
||||
state *state.State
|
||||
state *state.StateDB
|
||||
block *types.Block
|
||||
tx *types.Transaction
|
||||
depth int
|
||||
}
|
||||
|
||||
func NewEnv(state *state.State, tx *types.Transaction, block *types.Block) *VMEnv {
|
||||
func NewEnv(state *state.StateDB, tx *types.Transaction, block *types.Block) *VMEnv {
|
||||
return &VMEnv{
|
||||
state: state,
|
||||
block: block,
|
||||
@ -31,7 +31,7 @@ func (self *VMEnv) Time() int64 { return self.block.Time }
|
||||
func (self *VMEnv) Difficulty() *big.Int { return self.block.Difficulty }
|
||||
func (self *VMEnv) BlockHash() []byte { return self.block.Hash() }
|
||||
func (self *VMEnv) Value() *big.Int { return self.tx.Value }
|
||||
func (self *VMEnv) State() *state.State { return self.state }
|
||||
func (self *VMEnv) State() *state.StateDB { return self.state }
|
||||
func (self *VMEnv) GasLimit() *big.Int { return self.block.GasLimit }
|
||||
func (self *VMEnv) Depth() int { return self.depth }
|
||||
func (self *VMEnv) SetDepth(i int) { self.depth = i }
|
||||
|
Reference in New Issue
Block a user