diff options
author | obscuren <geffobscura@gmail.com> | 2014-08-04 16:42:40 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-08-04 16:42:40 +0800 |
commit | 03ce15df4c7ef51d4373233ab5c3766282b31771 (patch) | |
tree | 8e2487308508223b47b9a91a6eaa53e657a89312 | |
parent | 3debeb7236d2c8474fa9049cc91dc26bf1040b3f (diff) | |
download | dexon-03ce15df4c7ef51d4373233ab5c3766282b31771.tar dexon-03ce15df4c7ef51d4373233ab5c3766282b31771.tar.gz dexon-03ce15df4c7ef51d4373233ab5c3766282b31771.tar.bz2 dexon-03ce15df4c7ef51d4373233ab5c3766282b31771.tar.lz dexon-03ce15df4c7ef51d4373233ab5c3766282b31771.tar.xz dexon-03ce15df4c7ef51d4373233ab5c3766282b31771.tar.zst dexon-03ce15df4c7ef51d4373233ab5c3766282b31771.zip |
ethstate.NewState => ethstate.New
-rw-r--r-- | ethchain/block.go | 6 | ||||
-rw-r--r-- | ethchain/state_transition.go | 2 | ||||
-rw-r--r-- | ethstate/state.go | 4 | ||||
-rw-r--r-- | ethstate/state_object.go | 6 | ||||
-rw-r--r-- | ethstate/state_test.go | 5 |
5 files changed, 12 insertions, 11 deletions
diff --git a/ethchain/block.go b/ethchain/block.go index e4486f8e4..321af6183 100644 --- a/ethchain/block.go +++ b/ethchain/block.go @@ -100,7 +100,7 @@ func CreateBlock(root interface{}, } block.SetUncles([]*Block{}) - block.state = ethstate.NewState(ethtrie.New(ethutil.Config.Db, root)) + block.state = ethstate.New(ethtrie.New(ethutil.Config.Db, root)) return block } @@ -265,7 +265,7 @@ func (block *Block) RlpValueDecode(decoder *ethutil.Value) { block.PrevHash = header.Get(0).Bytes() block.UncleSha = header.Get(1).Bytes() block.Coinbase = header.Get(2).Bytes() - block.state = ethstate.NewState(ethtrie.New(ethutil.Config.Db, header.Get(3).Val)) + block.state = ethstate.New(ethtrie.New(ethutil.Config.Db, header.Get(3).Val)) block.TxSha = header.Get(4).Bytes() block.Difficulty = header.Get(5).BigInt() block.Number = header.Get(6).BigInt() @@ -307,7 +307,7 @@ func NewUncleBlockFromValue(header *ethutil.Value) *Block { block.PrevHash = header.Get(0).Bytes() block.UncleSha = header.Get(1).Bytes() block.Coinbase = header.Get(2).Bytes() - block.state = ethstate.NewState(ethtrie.New(ethutil.Config.Db, header.Get(3).Val)) + block.state = ethstate.New(ethtrie.New(ethutil.Config.Db, header.Get(3).Val)) block.TxSha = header.Get(4).Bytes() block.Difficulty = header.Get(5).BigInt() block.Number = header.Get(6).BigInt() diff --git a/ethchain/state_transition.go b/ethchain/state_transition.go index 8f1561c00..dfcbfcc04 100644 --- a/ethchain/state_transition.go +++ b/ethchain/state_transition.go @@ -278,7 +278,7 @@ func MakeContract(tx *Transaction, state *ethstate.State) *ethstate.StateObject contract := state.NewStateObject(addr) contract.InitCode = tx.Data - contract.State = ethstate.NewState(ethtrie.New(ethutil.Config.Db, "")) + contract.State = ethstate.New(ethtrie.New(ethutil.Config.Db, "")) return contract } diff --git a/ethstate/state.go b/ethstate/state.go index 693a591c3..10bcf6335 100644 --- a/ethstate/state.go +++ b/ethstate/state.go @@ -26,7 +26,7 @@ type State struct { } // Create a new state from a given trie -func NewState(trie *ethtrie.Trie) *State { +func New(trie *ethtrie.Trie) *State { return &State{Trie: trie, stateObjects: make(map[string]*StateObject), manifest: NewManifest()} } @@ -128,7 +128,7 @@ func (s *State) Cmp(other *State) bool { func (self *State) Copy() *State { if self.Trie != nil { - state := NewState(self.Trie.Copy()) + state := New(self.Trie.Copy()) for k, stateObject := range self.stateObjects { state.stateObjects[k] = stateObject.Copy() } diff --git a/ethstate/state_object.go b/ethstate/state_object.go index 309e3e762..67d09edd8 100644 --- a/ethstate/state_object.go +++ b/ethstate/state_object.go @@ -62,7 +62,7 @@ func NewStateObject(addr []byte) *StateObject { address := ethutil.Address(addr) object := &StateObject{address: address, Balance: new(big.Int), gasPool: new(big.Int)} - object.State = NewState(ethtrie.New(ethutil.Config.Db, "")) + object.State = New(ethtrie.New(ethutil.Config.Db, "")) object.storage = make(Storage) object.gasPool = new(big.Int) @@ -72,7 +72,7 @@ func NewStateObject(addr []byte) *StateObject { func NewContract(address []byte, balance *big.Int, root []byte) *StateObject { contract := NewStateObject(address) contract.Balance = balance - contract.State = NewState(ethtrie.New(ethutil.Config.Db, string(root))) + contract.State = New(ethtrie.New(ethutil.Config.Db, string(root))) return contract } @@ -300,7 +300,7 @@ func (c *StateObject) RlpDecode(data []byte) { c.Nonce = decoder.Get(0).Uint() c.Balance = decoder.Get(1).BigInt() - c.State = NewState(ethtrie.New(ethutil.Config.Db, decoder.Get(2).Interface())) + c.State = New(ethtrie.New(ethutil.Config.Db, decoder.Get(2).Interface())) c.storage = make(map[string]*ethutil.Value) c.gasPool = new(big.Int) diff --git a/ethstate/state_test.go b/ethstate/state_test.go index cd13e80bc..00c9de9d6 100644 --- a/ethstate/state_test.go +++ b/ethstate/state_test.go @@ -1,10 +1,11 @@ package ethstate import ( + "testing" + "github.com/ethereum/eth-go/ethdb" "github.com/ethereum/eth-go/ethtrie" "github.com/ethereum/eth-go/ethutil" - "testing" ) var ZeroHash256 = make([]byte, 32) @@ -14,7 +15,7 @@ func TestSnapshot(t *testing.T) { ethutil.ReadConfig(".ethtest", "/tmp/ethtest", "") ethutil.Config.Db = db - state := NewState(ethtrie.NewTrie(db, "")) + state := New(ethtrie.New(db, "")) stateObject := state.GetOrNewStateObject([]byte("aa")) |