aboutsummaryrefslogtreecommitdiffstats
path: root/state/statedb.go
diff options
context:
space:
mode:
Diffstat (limited to 'state/statedb.go')
-rw-r--r--state/statedb.go45
1 files changed, 23 insertions, 22 deletions
diff --git a/state/statedb.go b/state/statedb.go
index c83d59ed7..7e2b24b94 100644
--- a/state/statedb.go
+++ b/state/statedb.go
@@ -72,43 +72,42 @@ func (self *StateDB) AddBalance(addr []byte, amount *big.Int) {
func (self *StateDB) GetNonce(addr []byte) uint64 {
stateObject := self.GetStateObject(addr)
if stateObject != nil {
- return stateObject.Nonce
+ return stateObject.nonce
}
return 0
}
-func (self *StateDB) SetNonce(addr []byte, nonce uint64) {
+func (self *StateDB) GetCode(addr []byte) []byte {
stateObject := self.GetStateObject(addr)
if stateObject != nil {
- stateObject.Nonce = nonce
+ return stateObject.code
}
+
+ return nil
}
-func (self *StateDB) GetCode(addr []byte) []byte {
- stateObject := self.GetStateObject(addr)
+func (self *StateDB) GetState(a, b []byte) []byte {
+ stateObject := self.GetStateObject(a)
if stateObject != nil {
- return stateObject.Code
+ return stateObject.GetState(b).Bytes()
}
return nil
}
-func (self *StateDB) SetCode(addr, code []byte) {
+func (self *StateDB) SetNonce(addr []byte, nonce uint64) {
stateObject := self.GetStateObject(addr)
if stateObject != nil {
- stateObject.SetCode(code)
+ stateObject.SetNonce(nonce)
}
}
-// TODO vars
-func (self *StateDB) GetState(a, b []byte) []byte {
- stateObject := self.GetStateObject(a)
+func (self *StateDB) SetCode(addr, code []byte) {
+ stateObject := self.GetStateObject(addr)
if stateObject != nil {
- return stateObject.GetState(b).Bytes()
+ stateObject.SetCode(code)
}
-
- return nil
}
func (self *StateDB) SetState(addr, key []byte, value interface{}) {
@@ -138,7 +137,7 @@ func (self *StateDB) UpdateStateObject(stateObject *StateObject) {
addr := stateObject.Address()
if len(stateObject.CodeHash()) > 0 {
- self.db.Put(stateObject.CodeHash(), stateObject.Code)
+ self.db.Put(stateObject.CodeHash(), stateObject.code)
}
self.trie.Update(addr, stateObject.RlpEncode())
@@ -282,16 +281,18 @@ func (self *StateDB) Refunds() map[string]*big.Int {
}
func (self *StateDB) Update(gasUsed *big.Int) {
-
self.refund = make(map[string]*big.Int)
for _, stateObject := range self.stateObjects {
- if stateObject.remove {
- self.DeleteStateObject(stateObject)
- } else {
- stateObject.Sync()
-
- self.UpdateStateObject(stateObject)
+ if stateObject.dirty {
+ if stateObject.remove {
+ self.DeleteStateObject(stateObject)
+ } else {
+ stateObject.Sync()
+
+ self.UpdateStateObject(stateObject)
+ }
+ stateObject.dirty = false
}
}
}