aboutsummaryrefslogtreecommitdiffstats
path: root/state/statedb.go
diff options
context:
space:
mode:
authorAlexandre Van de Sande <alex.vandesande@ethdev.com>2015-02-23 20:05:15 +0800
committerAlexandre Van de Sande <alex.vandesande@ethdev.com>2015-02-23 20:05:15 +0800
commitdea65840186fe861017524c9cb59ae07ac97ed06 (patch)
tree5cb5e339b9ce77a2a3c92cf8a10c4294fcf7965c /state/statedb.go
parentbb3338df6363d8267a24190584f0908463241a6c (diff)
parentdd086791acf477da7641c168f82de70ed0b2dca6 (diff)
downloaddexon-dea65840186fe861017524c9cb59ae07ac97ed06.tar
dexon-dea65840186fe861017524c9cb59ae07ac97ed06.tar.gz
dexon-dea65840186fe861017524c9cb59ae07ac97ed06.tar.bz2
dexon-dea65840186fe861017524c9cb59ae07ac97ed06.tar.lz
dexon-dea65840186fe861017524c9cb59ae07ac97ed06.tar.xz
dexon-dea65840186fe861017524c9cb59ae07ac97ed06.tar.zst
dexon-dea65840186fe861017524c9cb59ae07ac97ed06.zip
Merge branch 'develop' into ui
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
}
}
}