@@ -198,25 +198,10 @@ func (s *stateObject) GetCommittedState(db Database, key common.Hash) common.Has
198
198
}
199
199
// If no live objects are available, attempt to use snapshots
200
200
var (
201
- enc []byte
202
- err error
203
- meter * time.Duration
201
+ enc []byte
202
+ err error
204
203
)
205
- readStart := time .Now ()
206
- if metrics .EnabledExpensive {
207
- // If the snap is 'under construction', the first lookup may fail. If that
208
- // happens, we don't want to double-count the time elapsed. Thus this
209
- // dance with the metering.
210
- defer func () {
211
- if meter != nil {
212
- * meter += time .Since (readStart )
213
- }
214
- }()
215
- }
216
204
if s .db .snap != nil {
217
- if metrics .EnabledExpensive {
218
- meter = & s .db .SnapshotStorageReads
219
- }
220
205
// If the object was destructed in *this* block (and potentially resurrected),
221
206
// the storage has been cleared out, and we should *not* consult the previous
222
207
// snapshot about any storage values. The only possible alternatives are:
@@ -226,20 +211,20 @@ func (s *stateObject) GetCommittedState(db Database, key common.Hash) common.Has
226
211
if _ , destructed := s .db .snapDestructs [s .addrHash ]; destructed {
227
212
return common.Hash {}
228
213
}
214
+ start := time .Now ()
229
215
enc , err = s .db .snap .Storage (s .addrHash , crypto .Keccak256Hash (key .Bytes ()))
216
+ if metrics .EnabledExpensive {
217
+ s .db .SnapshotStorageReads += time .Since (start )
218
+ }
230
219
}
231
220
// If the snapshot is unavailable or reading from it fails, load from the database.
232
221
if s .db .snap == nil || err != nil {
233
- if meter != nil {
234
- // If we already spent time checking the snapshot, account for it
235
- // and reset the readStart
236
- * meter += time .Since (readStart )
237
- readStart = time .Now ()
238
- }
222
+ start := time .Now ()
223
+ enc , err = s .getTrie (db ).TryGet (key .Bytes ())
239
224
if metrics .EnabledExpensive {
240
- meter = & s .db .StorageReads
225
+ s .db .StorageReads += time . Since ( start )
241
226
}
242
- if enc , err = s . getTrie ( db ). TryGet ( key . Bytes ()); err != nil {
227
+ if err != nil {
243
228
s .setError (err )
244
229
return common.Hash {}
245
230
}
0 commit comments