@@ -65,7 +65,7 @@ func NewStateObject(addr []byte, db ethutil.Database) *StateObject {
65
65
// This to ensure that it has 20 bytes (and not 0 bytes), thus left or right pad doesn't matter.
66
66
address := ethutil .Address (addr )
67
67
68
- object := & StateObject {db : db , address : address , balance : new (big.Int ), gasPool : new (big.Int )}
68
+ object := & StateObject {db : db , address : address , balance : new (big.Int ), gasPool : new (big.Int ), dirty : true }
69
69
object .State = New (nil , db ) //New(trie.New(ethutil.Config.Db, ""))
70
70
object .storage = make (Storage )
71
71
object .gasPool = new (big.Int )
@@ -118,6 +118,7 @@ func (self *StateObject) GetStorage(key *big.Int) *ethutil.Value {
118
118
}
119
119
func (self * StateObject ) SetStorage (key * big.Int , value * ethutil.Value ) {
120
120
self .SetState (key .Bytes (), value )
121
+ self .dirty = true
121
122
}
122
123
123
124
func (self * StateObject ) Storage () map [string ]* ethutil.Value {
@@ -142,6 +143,7 @@ func (self *StateObject) GetState(k []byte) *ethutil.Value {
142
143
func (self * StateObject ) SetState (k []byte , value * ethutil.Value ) {
143
144
key := ethutil .LeftPadBytes (k , 32 )
144
145
self .storage [string (key )] = value .Copy ()
146
+ self .dirty = true
145
147
}
146
148
147
149
func (self * StateObject ) Sync () {
@@ -166,6 +168,7 @@ func (c *StateObject) GetInstr(pc *big.Int) *ethutil.Value {
166
168
167
169
func (c * StateObject ) AddBalance (amount * big.Int ) {
168
170
c .SetBalance (new (big.Int ).Add (c .balance , amount ))
171
+ c .dirty = true
169
172
170
173
statelogger .Debugf ("%x: #%d %v (+ %v)\n " , c .Address (), c .Nonce , c .balance , amount )
171
174
}
@@ -180,6 +183,7 @@ func (c *StateObject) SubAmount(amount *big.Int) { c.SubBalance(amount) }
180
183
181
184
func (c * StateObject ) SetBalance (amount * big.Int ) {
182
185
c .balance = amount
186
+ c .dirty = true
183
187
}
184
188
185
189
func (self * StateObject ) Balance () * big.Int { return self .balance }
@@ -198,6 +202,8 @@ func (c *StateObject) ConvertGas(gas, price *big.Int) error {
198
202
199
203
c .SubAmount (total )
200
204
205
+ c .dirty = true
206
+
201
207
return nil
202
208
}
203
209
@@ -219,6 +225,8 @@ func (self *StateObject) BuyGas(gas, price *big.Int) error {
219
225
220
226
self .AddAmount (rGas )
221
227
228
+ self .dirty = true
229
+
222
230
return nil
223
231
}
224
232
0 commit comments