@@ -36,11 +36,11 @@ type StateObject struct {
36
36
// Shared attributes
37
37
balance * big.Int
38
38
codeHash []byte
39
- Nonce uint64
39
+ nonce uint64
40
40
// Contract related attributes
41
41
State * StateDB
42
- Code Code
43
- InitCode Code
42
+ code Code
43
+ initCode Code
44
44
45
45
storage Storage
46
46
@@ -89,20 +89,21 @@ func NewStateObjectFromBytes(address, data []byte, db ethutil.Database) *StateOb
89
89
90
90
object := & StateObject {address : address , db : db }
91
91
//object.RlpDecode(data)
92
- object .Nonce = extobject .Nonce
92
+ object .nonce = extobject .Nonce
93
93
object .balance = extobject .Balance
94
94
object .codeHash = extobject .CodeHash
95
95
object .State = New (extobject .Root , db )
96
96
object .storage = make (map [string ]* ethutil.Value )
97
97
object .gasPool = new (big.Int )
98
- object .Code , _ = db .Get (extobject .CodeHash )
98
+ object .code , _ = db .Get (extobject .CodeHash )
99
99
100
100
return object
101
101
}
102
102
103
103
func (self * StateObject ) MarkForDeletion () {
104
104
self .remove = true
105
- statelogger .DebugDetailf ("%x: #%d %v (deletion)\n " , self .Address (), self .Nonce , self .balance )
105
+ self .dirty = true
106
+ statelogger .DebugDetailf ("%x: #%d %v (deletion)\n " , self .Address (), self .nonce , self .balance )
106
107
}
107
108
108
109
func (c * StateObject ) getAddr (addr []byte ) * ethutil.Value {
@@ -159,25 +160,24 @@ func (self *StateObject) Sync() {
159
160
}
160
161
161
162
func (c * StateObject ) GetInstr (pc * big.Int ) * ethutil.Value {
162
- if int64 (len (c .Code )- 1 ) < pc .Int64 () {
163
+ if int64 (len (c .code )- 1 ) < pc .Int64 () {
163
164
return ethutil .NewValue (0 )
164
165
}
165
166
166
- return ethutil .NewValueFromBytes ([]byte {c .Code [pc .Int64 ()]})
167
+ return ethutil .NewValueFromBytes ([]byte {c .code [pc .Int64 ()]})
167
168
}
168
169
169
170
func (c * StateObject ) AddBalance (amount * big.Int ) {
170
171
c .SetBalance (new (big.Int ).Add (c .balance , amount ))
171
- c .dirty = true
172
172
173
- statelogger .Debugf ("%x: #%d %v (+ %v)\n " , c .Address (), c .Nonce , c .balance , amount )
173
+ statelogger .Debugf ("%x: #%d %v (+ %v)\n " , c .Address (), c .nonce , c .balance , amount )
174
174
}
175
175
func (c * StateObject ) AddAmount (amount * big.Int ) { c .AddBalance (amount ) }
176
176
177
177
func (c * StateObject ) SubBalance (amount * big.Int ) {
178
178
c .SetBalance (new (big.Int ).Sub (c .balance , amount ))
179
179
180
- statelogger .Debugf ("%x: #%d %v (- %v)\n " , c .Address (), c .Nonce , c .balance , amount )
180
+ statelogger .Debugf ("%x: #%d %v (- %v)\n " , c .Address (), c .nonce , c .balance , amount )
181
181
}
182
182
func (c * StateObject ) SubAmount (amount * big.Int ) { c .SubBalance (amount ) }
183
183
@@ -186,8 +186,6 @@ func (c *StateObject) SetBalance(amount *big.Int) {
186
186
c .dirty = true
187
187
}
188
188
189
- func (self * StateObject ) Balance () * big.Int { return self .balance }
190
-
191
189
//
192
190
// Gas setters and getters
193
191
//
@@ -243,12 +241,12 @@ func (self *StateObject) Copy() *StateObject {
243
241
stateObject := NewStateObject (self .Address (), self .db )
244
242
stateObject .balance .Set (self .balance )
245
243
stateObject .codeHash = ethutil .CopyBytes (self .codeHash )
246
- stateObject .Nonce = self .Nonce
244
+ stateObject .nonce = self .nonce
247
245
if self .State != nil {
248
246
stateObject .State = self .State .Copy ()
249
247
}
250
- stateObject .Code = ethutil .CopyBytes (self .Code )
251
- stateObject .InitCode = ethutil .CopyBytes (self .InitCode )
248
+ stateObject .code = ethutil .CopyBytes (self .code )
249
+ stateObject .initCode = ethutil .CopyBytes (self .initCode )
252
250
stateObject .storage = self .storage .Copy ()
253
251
stateObject .gasPool .Set (self .gasPool )
254
252
stateObject .remove = self .remove
@@ -265,8 +263,12 @@ func (self *StateObject) Set(stateObject *StateObject) {
265
263
// Attribute accessors
266
264
//
267
265
266
+ func (self * StateObject ) Balance () * big.Int {
267
+ return self .balance
268
+ }
269
+
268
270
func (c * StateObject ) N () * big.Int {
269
- return big .NewInt (int64 (c .Nonce ))
271
+ return big .NewInt (int64 (c .nonce ))
270
272
}
271
273
272
274
// Returns the address of the contract/account
@@ -276,7 +278,7 @@ func (c *StateObject) Address() []byte {
276
278
277
279
// Returns the initialization Code
278
280
func (c * StateObject ) Init () Code {
279
- return c .InitCode
281
+ return c .initCode
280
282
}
281
283
282
284
func (self * StateObject ) Trie () * trie.Trie {
@@ -287,8 +289,27 @@ func (self *StateObject) Root() []byte {
287
289
return self .Trie ().Root ()
288
290
}
289
291
292
+ func (self * StateObject ) Code () []byte {
293
+ return self .code
294
+ }
295
+
290
296
func (self * StateObject ) SetCode (code []byte ) {
291
- self .Code = code
297
+ self .code = code
298
+ self .dirty = true
299
+ }
300
+
301
+ func (self * StateObject ) SetInitCode (code []byte ) {
302
+ self .initCode = code
303
+ self .dirty = true
304
+ }
305
+
306
+ func (self * StateObject ) SetNonce (nonce uint64 ) {
307
+ self .nonce = nonce
308
+ self .dirty = true
309
+ }
310
+
311
+ func (self * StateObject ) Nonce () uint64 {
312
+ return self .nonce
292
313
}
293
314
294
315
//
@@ -297,24 +318,24 @@ func (self *StateObject) SetCode(code []byte) {
297
318
298
319
// State object encoding methods
299
320
func (c * StateObject ) RlpEncode () []byte {
300
- return ethutil .Encode ([]interface {}{c .Nonce , c .balance , c .Root (), c .CodeHash ()})
321
+ return ethutil .Encode ([]interface {}{c .nonce , c .balance , c .Root (), c .CodeHash ()})
301
322
}
302
323
303
324
func (c * StateObject ) CodeHash () ethutil.Bytes {
304
- return crypto .Sha3 (c .Code )
325
+ return crypto .Sha3 (c .code )
305
326
}
306
327
307
328
func (c * StateObject ) RlpDecode (data []byte ) {
308
329
decoder := ethutil .NewValueFromBytes (data )
309
- c .Nonce = decoder .Get (0 ).Uint ()
330
+ c .nonce = decoder .Get (0 ).Uint ()
310
331
c .balance = decoder .Get (1 ).BigInt ()
311
332
c .State = New (decoder .Get (2 ).Bytes (), c .db ) //New(trie.New(ethutil.Config.Db, decoder.Get(2).Interface()))
312
333
c .storage = make (map [string ]* ethutil.Value )
313
334
c .gasPool = new (big.Int )
314
335
315
336
c .codeHash = decoder .Get (3 ).Bytes ()
316
337
317
- c .Code , _ = c .db .Get (c .codeHash )
338
+ c .code , _ = c .db .Get (c .codeHash )
318
339
}
319
340
320
341
// Storage change object. Used by the manifest for notifying changes to
0 commit comments