@@ -23,14 +23,14 @@ type StateDB struct {
23
23
24
24
manifest * Manifest
25
25
26
- refund map [string ][] * big.Int
26
+ refund map [string ]* big.Int
27
27
28
28
logs Logs
29
29
}
30
30
31
31
// Create a new state from a given trie
32
32
func New (trie * trie.Trie ) * StateDB {
33
- return & StateDB {Trie : trie , stateObjects : make (map [string ]* StateObject ), manifest : NewManifest (), refund : make (map [string ][] * big.Int )}
33
+ return & StateDB {Trie : trie , stateObjects : make (map [string ]* StateObject ), manifest : NewManifest (), refund : make (map [string ]* big.Int )}
34
34
}
35
35
36
36
func (self * StateDB ) EmptyLogs () {
@@ -56,7 +56,10 @@ func (self *StateDB) GetBalance(addr []byte) *big.Int {
56
56
}
57
57
58
58
func (self * StateDB ) Refund (addr []byte , gas * big.Int ) {
59
- self .refund [string (addr )] = append (self .refund [string (addr )], gas )
59
+ if self .refund [string (addr )] == nil {
60
+ self .refund [string (addr )] = new (big.Int )
61
+ }
62
+ self .refund [string (addr )].Add (self .refund [string (addr )], gas )
60
63
}
61
64
62
65
func (self * StateDB ) AddBalance (addr []byte , amount * big.Int ) {
@@ -207,7 +210,7 @@ func (self *StateDB) Copy() *StateDB {
207
210
}
208
211
209
212
for addr , refund := range self .refund {
210
- state .refund [addr ] = refund
213
+ state .refund [addr ] = new (big. Int ). Set ( refund )
211
214
}
212
215
213
216
logs := make (Logs , len (self .logs ))
@@ -269,17 +272,17 @@ func (s *StateDB) Sync() {
269
272
270
273
func (self * StateDB ) Empty () {
271
274
self .stateObjects = make (map [string ]* StateObject )
272
- self .refund = make (map [string ][] * big.Int )
275
+ self .refund = make (map [string ]* big.Int )
273
276
}
274
277
275
- func (self * StateDB ) Refunds () map [string ][] * big.Int {
278
+ func (self * StateDB ) Refunds () map [string ]* big.Int {
276
279
return self .refund
277
280
}
278
281
279
282
func (self * StateDB ) Update (gasUsed * big.Int ) {
280
283
var deleted bool
281
284
282
- self .refund = make (map [string ][] * big.Int )
285
+ self .refund = make (map [string ]* big.Int )
283
286
284
287
for _ , stateObject := range self .stateObjects {
285
288
if stateObject .remove {
0 commit comments