@@ -198,25 +198,10 @@ func (s *stateObject) GetCommittedState(db Database, key common.Hash) common.Has
198198 }
199199 // If no live objects are available, attempt to use snapshots
200200 var (
201- enc []byte
202- err error
203- meter * time.Duration
201+ enc []byte
202+ err error
204203 )
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- }
216204 if s .db .snap != nil {
217- if metrics .EnabledExpensive {
218- meter = & s .db .SnapshotStorageReads
219- }
220205 // If the object was destructed in *this* block (and potentially resurrected),
221206 // the storage has been cleared out, and we should *not* consult the previous
222207 // 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
226211 if _ , destructed := s .db .snapDestructs [s .addrHash ]; destructed {
227212 return common.Hash {}
228213 }
214+ start := time .Now ()
229215 enc , err = s .db .snap .Storage (s .addrHash , crypto .Keccak256Hash (key .Bytes ()))
216+ if metrics .EnabledExpensive {
217+ s .db .SnapshotStorageReads += time .Since (start )
218+ }
230219 }
231220 // If the snapshot is unavailable or reading from it fails, load from the database.
232221 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 ())
239224 if metrics .EnabledExpensive {
240- meter = & s .db .StorageReads
225+ s .db .StorageReads += time . Since ( start )
241226 }
242- if enc , err = s . getTrie ( db ). TryGet ( key . Bytes ()); err != nil {
227+ if err != nil {
243228 s .setError (err )
244229 return common.Hash {}
245230 }
0 commit comments