diff options
Diffstat (limited to 'chain')
-rw-r--r-- | chain/block.go | 10 | ||||
-rw-r--r-- | chain/bloom9.go | 4 | ||||
-rw-r--r-- | chain/filter.go | 12 | ||||
-rw-r--r-- | chain/state_manager.go | 24 | ||||
-rw-r--r-- | chain/state_transition.go | 26 | ||||
-rw-r--r-- | chain/transaction.go | 8 | ||||
-rw-r--r-- | chain/transaction_pool.go | 4 | ||||
-rw-r--r-- | chain/vm_env.go | 28 |
8 files changed, 58 insertions, 58 deletions
diff --git a/chain/block.go b/chain/block.go index abad6f3d2..7e39aa2c9 100644 --- a/chain/block.go +++ b/chain/block.go @@ -8,9 +8,9 @@ import ( "time" "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/ethstate" "github.com/ethereum/go-ethereum/ethtrie" "github.com/ethereum/go-ethereum/ethutil" + "github.com/ethereum/go-ethereum/state" ) type BlockInfo struct { @@ -77,7 +77,7 @@ type Block struct { Coinbase []byte // Block Trie state //state *ethutil.Trie - state *ethstate.State + state *state.State // Difficulty for the current block Difficulty *big.Int // Creation time @@ -137,7 +137,7 @@ func CreateBlock(root interface{}, } block.SetUncles([]*Block{}) - block.state = ethstate.New(ethtrie.New(ethutil.Config.Db, root)) + block.state = state.New(ethtrie.New(ethutil.Config.Db, root)) return block } @@ -152,7 +152,7 @@ func (block *Block) HashNoNonce() []byte { return crypto.Sha3(ethutil.Encode(block.miningHeader())) } -func (block *Block) State() *ethstate.State { +func (block *Block) State() *state.State { return block.state } @@ -294,7 +294,7 @@ func (self *Block) setHeader(header *ethutil.Value) { self.PrevHash = header.Get(0).Bytes() self.UncleSha = header.Get(1).Bytes() self.Coinbase = header.Get(2).Bytes() - self.state = ethstate.New(ethtrie.New(ethutil.Config.Db, header.Get(3).Val)) + self.state = state.New(ethtrie.New(ethutil.Config.Db, header.Get(3).Val)) self.TxSha = header.Get(4).Bytes() self.ReceiptSha = header.Get(5).Bytes() self.LogsBloom = header.Get(6).Bytes() diff --git a/chain/bloom9.go b/chain/bloom9.go index 60cafdb4b..ced31cc30 100644 --- a/chain/bloom9.go +++ b/chain/bloom9.go @@ -3,8 +3,8 @@ package chain import ( "math/big" - "github.com/ethereum/go-ethereum/ethstate" "github.com/ethereum/go-ethereum/ethutil" + "github.com/ethereum/go-ethereum/state" ) func CreateBloom(block *Block) []byte { @@ -17,7 +17,7 @@ func CreateBloom(block *Block) []byte { return bin.Bytes() } -func LogsBloom(logs ethstate.Logs) *big.Int { +func LogsBloom(logs state.Logs) *big.Int { bin := new(big.Int) for _, log := range logs { data := [][]byte{log.Address} diff --git a/chain/filter.go b/chain/filter.go index 2aecb4f58..0265a60fa 100644 --- a/chain/filter.go +++ b/chain/filter.go @@ -4,7 +4,7 @@ import ( "bytes" "math" - "github.com/ethereum/go-ethereum/ethstate" + "github.com/ethereum/go-ethereum/state" ) type AccountChange struct { @@ -23,7 +23,7 @@ type Filter struct { Altered []AccountChange BlockCallback func(*Block) - MessageCallback func(ethstate.Messages) + MessageCallback func(state.Messages) } // Create a new filter which uses a bloom filter on blocks to figure out whether a particular block @@ -72,7 +72,7 @@ func (self *Filter) SetSkip(skip int) { } // Run filters messages with the current parameters set -func (self *Filter) Find() []*ethstate.Message { +func (self *Filter) Find() []*state.Message { var earliestBlockNo uint64 = uint64(self.earliest) if self.earliest == -1 { earliestBlockNo = self.eth.ChainManager().CurrentBlock.Number.Uint64() @@ -83,7 +83,7 @@ func (self *Filter) Find() []*ethstate.Message { } var ( - messages []*ethstate.Message + messages []*state.Message block = self.eth.ChainManager().GetBlockByNumber(latestBlockNo) quit bool ) @@ -128,8 +128,8 @@ func includes(addresses [][]byte, a []byte) (found bool) { return } -func (self *Filter) FilterMessages(msgs []*ethstate.Message) []*ethstate.Message { - var messages []*ethstate.Message +func (self *Filter) FilterMessages(msgs []*state.Message) []*state.Message { + var messages []*state.Message // Filter the messages for interesting stuff for _, message := range msgs { diff --git a/chain/state_manager.go b/chain/state_manager.go index 8266726f5..b6bfbc22f 100644 --- a/chain/state_manager.go +++ b/chain/state_manager.go @@ -10,11 +10,11 @@ import ( "time" "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/ethstate" "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/ethwire" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/state" ) var statelogger = logger.NewLogger("BLOCK") @@ -61,10 +61,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 *ethstate.State + transState *state.State // Mining state. The mining state is used purely and solely by the mining // operation. - miningState *ethstate.State + miningState *state.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 @@ -112,19 +112,19 @@ func (self *StateManager) updateThread() { } } -func (sm *StateManager) CurrentState() *ethstate.State { +func (sm *StateManager) CurrentState() *state.State { return sm.eth.ChainManager().CurrentBlock.State() } -func (sm *StateManager) TransState() *ethstate.State { +func (sm *StateManager) TransState() *state.State { return sm.transState } -func (sm *StateManager) MiningState() *ethstate.State { +func (sm *StateManager) MiningState() *state.State { return sm.miningState } -func (sm *StateManager) NewMiningState() *ethstate.State { +func (sm *StateManager) NewMiningState() *state.State { sm.miningState = sm.eth.ChainManager().CurrentBlock.State().Copy() return sm.miningState @@ -134,7 +134,7 @@ func (sm *StateManager) ChainManager() *ChainManager { return sm.bc } -func (self *StateManager) ProcessTransactions(coinbase *ethstate.StateObject, state *ethstate.State, block, parent *Block, txs Transactions) (Receipts, Transactions, Transactions, Transactions, error) { +func (self *StateManager) ProcessTransactions(coinbase *state.StateObject, state *state.State, block, parent *Block, txs Transactions) (Receipts, Transactions, Transactions, Transactions, error) { var ( receipts Receipts handled, unhandled Transactions @@ -296,7 +296,7 @@ func (sm *StateManager) Process(block *Block) (err error) { return nil } -func (sm *StateManager) ApplyDiff(state *ethstate.State, parent, block *Block) (receipts Receipts, err error) { +func (sm *StateManager) ApplyDiff(state *state.State, parent, block *Block) (receipts Receipts, err error) { coinbase := state.GetOrNewStateObject(block.Coinbase) coinbase.SetGasPool(block.CalcGasLimit(parent)) @@ -372,7 +372,7 @@ func (sm *StateManager) ValidateBlock(block *Block) error { return nil } -func (sm *StateManager) AccumelateRewards(state *ethstate.State, block, parent *Block) error { +func (sm *StateManager) AccumelateRewards(state *state.State, block, parent *Block) error { reward := new(big.Int).Set(BlockReward) knownUncles := ethutil.Set(parent.Uncles) @@ -416,7 +416,7 @@ func (sm *StateManager) AccumelateRewards(state *ethstate.State, block, parent * } // Manifest will handle both creating notifications and generating bloom bin data -func (sm *StateManager) createBloomFilter(state *ethstate.State) *BloomFilter { +func (sm *StateManager) createBloomFilter(state *state.State) *BloomFilter { bloomf := NewBloomFilter(nil) for _, msg := range state.Manifest().Messages { @@ -429,7 +429,7 @@ func (sm *StateManager) createBloomFilter(state *ethstate.State) *BloomFilter { return bloomf } -func (sm *StateManager) GetMessages(block *Block) (messages []*ethstate.Message, err error) { +func (sm *StateManager) GetMessages(block *Block) (messages []*state.Message, err error) { if !sm.bc.HasBlock(block.PrevHash) { return nil, ParentError(block.PrevHash) } diff --git a/chain/state_transition.go b/chain/state_transition.go index 4c62633c5..41bdadedb 100644 --- a/chain/state_transition.go +++ b/chain/state_transition.go @@ -4,8 +4,8 @@ import ( "fmt" "math/big" - "github.com/ethereum/go-ethereum/ethstate" "github.com/ethereum/go-ethereum/ethutil" + "github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/vm" ) @@ -31,17 +31,17 @@ type StateTransition struct { gas, gasPrice *big.Int value *big.Int data []byte - state *ethstate.State + state *state.State block *Block - cb, rec, sen *ethstate.StateObject + cb, rec, sen *state.StateObject } -func NewStateTransition(coinbase *ethstate.StateObject, tx *Transaction, state *ethstate.State, block *Block) *StateTransition { +func NewStateTransition(coinbase *state.StateObject, tx *Transaction, state *state.State, block *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} } -func (self *StateTransition) Coinbase() *ethstate.StateObject { +func (self *StateTransition) Coinbase() *state.StateObject { if self.cb != nil { return self.cb } @@ -49,7 +49,7 @@ func (self *StateTransition) Coinbase() *ethstate.StateObject { self.cb = self.state.GetOrNewStateObject(self.coinbase) return self.cb } -func (self *StateTransition) Sender() *ethstate.StateObject { +func (self *StateTransition) Sender() *state.StateObject { if self.sen != nil { return self.sen } @@ -58,7 +58,7 @@ func (self *StateTransition) Sender() *ethstate.StateObject { return self.sen } -func (self *StateTransition) Receiver() *ethstate.StateObject { +func (self *StateTransition) Receiver() *state.StateObject { if self.tx != nil && self.tx.CreatesContract() { return nil } @@ -143,7 +143,7 @@ func (self *StateTransition) TransitionState() (err error) { var ( tx = self.tx sender = self.Sender() - receiver *ethstate.StateObject + receiver *state.StateObject ) defer self.RefundGas() @@ -167,7 +167,7 @@ func (self *StateTransition) TransitionState() (err error) { return fmt.Errorf("Insufficient funds to transfer value. Req %v, has %v", self.value, sender.Balance) } - var snapshot *ethstate.State + var snapshot *state.State // If the receiver is nil it's a contract (\0*32). if tx.CreatesContract() { // Subtract the (irreversible) amount from the senders account @@ -195,7 +195,7 @@ func (self *StateTransition) TransitionState() (err error) { snapshot = self.state.Copy() } - msg := self.state.Manifest().AddMessage(ðstate.Message{ + msg := self.state.Manifest().AddMessage(&state.Message{ To: receiver.Address(), From: sender.Address(), Input: self.tx.Data, Origin: sender.Address(), @@ -232,14 +232,14 @@ func (self *StateTransition) TransitionState() (err error) { } else { // Add default LOG. Default = big(sender.addr) + 1 addr := ethutil.BigD(receiver.Address()) - self.state.AddLog(ethstate.Log{sender.Address(), [][]byte{ethutil.U256(addr.Add(addr, ethutil.Big1)).Bytes()}, nil}) + self.state.AddLog(state.Log{sender.Address(), [][]byte{ethutil.U256(addr.Add(addr, ethutil.Big1)).Bytes()}, nil}) } } return } -func (self *StateTransition) Eval(msg *ethstate.Message, script []byte, context *ethstate.StateObject) (ret []byte, err error) { +func (self *StateTransition) Eval(msg *state.Message, script []byte, context *state.StateObject) (ret []byte, err error) { var ( transactor = self.Sender() state = self.state @@ -254,7 +254,7 @@ func (self *StateTransition) Eval(msg *ethstate.Message, script []byte, context } // Converts an transaction in to a state object -func MakeContract(tx *Transaction, state *ethstate.State) *ethstate.StateObject { +func MakeContract(tx *Transaction, state *state.State) *state.StateObject { addr := tx.CreationAddress(state) contract := state.GetOrNewStateObject(addr) diff --git a/chain/transaction.go b/chain/transaction.go index 416ffbc6c..d393f0384 100644 --- a/chain/transaction.go +++ b/chain/transaction.go @@ -6,8 +6,8 @@ import ( "math/big" "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/ethstate" "github.com/ethereum/go-ethereum/ethutil" + "github.com/ethereum/go-ethereum/state" "github.com/obscuren/secp256k1-go" ) @@ -78,7 +78,7 @@ func (tx *Transaction) IsContract() bool { return tx.CreatesContract() } -func (tx *Transaction) CreationAddress(state *ethstate.State) []byte { +func (tx *Transaction) CreationAddress(state *state.State) []byte { // Generate a new address addr := crypto.Sha3(ethutil.NewValue([]interface{}{tx.Sender(), tx.Nonce}).Encode())[12:] //for i := uint64(0); state.GetStateObject(addr) != nil; i++ { @@ -205,7 +205,7 @@ type Receipt struct { PostState []byte CumulativeGasUsed *big.Int Bloom []byte - logs ethstate.Logs + logs state.Logs } func NewRecieptFromValue(val *ethutil.Value) *Receipt { @@ -222,7 +222,7 @@ func (self *Receipt) RlpValueDecode(decoder *ethutil.Value) { it := decoder.Get(3).NewIterator() for it.Next() { - self.logs = append(self.logs, ethstate.NewLogFromValue(it.Value())) + self.logs = append(self.logs, state.NewLogFromValue(it.Value())) } } diff --git a/chain/transaction_pool.go b/chain/transaction_pool.go index 21d501dfc..3e3787eed 100644 --- a/chain/transaction_pool.go +++ b/chain/transaction_pool.go @@ -7,9 +7,9 @@ import ( "math/big" "sync" - "github.com/ethereum/go-ethereum/ethstate" "github.com/ethereum/go-ethereum/ethwire" "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/state" ) var txplogger = logger.NewLogger("TXP") @@ -193,7 +193,7 @@ func (pool *TxPool) CurrentTransactions() []*Transaction { return txList } -func (pool *TxPool) RemoveInvalid(state *ethstate.State) { +func (pool *TxPool) RemoveInvalid(state *state.State) { pool.mutex.Lock() defer pool.mutex.Unlock() diff --git a/chain/vm_env.go b/chain/vm_env.go index d42351713..53092bd10 100644 --- a/chain/vm_env.go +++ b/chain/vm_env.go @@ -3,17 +3,17 @@ package chain import ( "math/big" - "github.com/ethereum/go-ethereum/ethstate" + "github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/vm" ) type VMEnv struct { - state *ethstate.State + state *state.State block *Block tx *Transaction } -func NewEnv(state *ethstate.State, tx *Transaction, block *Block) *VMEnv { +func NewEnv(state *state.State, tx *Transaction, block *Block) *VMEnv { return &VMEnv{ state: state, block: block, @@ -21,17 +21,17 @@ func NewEnv(state *ethstate.State, tx *Transaction, block *Block) *VMEnv { } } -func (self *VMEnv) Origin() []byte { return self.tx.Sender() } -func (self *VMEnv) BlockNumber() *big.Int { return self.block.Number } -func (self *VMEnv) PrevHash() []byte { return self.block.PrevHash } -func (self *VMEnv) Coinbase() []byte { return self.block.Coinbase } -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() *ethstate.State { return self.state } -func (self *VMEnv) GasLimit() *big.Int { return self.block.GasLimit } -func (self *VMEnv) AddLog(log ethstate.Log) { +func (self *VMEnv) Origin() []byte { return self.tx.Sender() } +func (self *VMEnv) BlockNumber() *big.Int { return self.block.Number } +func (self *VMEnv) PrevHash() []byte { return self.block.PrevHash } +func (self *VMEnv) Coinbase() []byte { return self.block.Coinbase } +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) GasLimit() *big.Int { return self.block.GasLimit } +func (self *VMEnv) AddLog(log state.Log) { self.state.AddLog(log) } func (self *VMEnv) Transfer(from, to vm.Account, amount *big.Int) error { |