ethstate.NewState => ethstate.New
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
@@ -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)
|
||||
|
||||
|
@@ -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"))
|
||||
|
||||
|
Reference in New Issue
Block a user