Skip to content

Commit fd2dd39

Browse files
committed
nil
Signed-off-by: jsvisa <delweng@gmail.com>
1 parent d18edda commit fd2dd39

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

core/state/snapshot/snapshot.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -390,15 +390,17 @@ func (t *Tree) Cap(root common.Hash, layers int) error {
390390
}
391391

392392
// Update the cache stats
393-
var stats fastcache.Stats
394-
diff.origin.cache.UpdateStats(&stats)
395-
snapshotCacheGetGauge.Update(int64(stats.GetCalls))
396-
snapshotCacheSetGauge.Update(int64(stats.SetCalls))
397-
snapshotCacheMissGauge.Update(int64(stats.Misses))
398-
snapshotCacheSizeGauge.Update(int64(stats.BytesSize))
399-
snapshotCacheCapacityGauge.Update(int64(stats.MaxBytesSize))
400-
snapshotCacheEntriesGauge.Update(int64(stats.EntriesCount))
401-
snapshotCacheCollisionGauge.Update(int64(stats.Collisions))
393+
if diff.origin != nil && diff.origin.cache != nil {
394+
var stats fastcache.Stats
395+
diff.origin.cache.UpdateStats(&stats)
396+
snapshotCacheGetGauge.Update(int64(stats.GetCalls))
397+
snapshotCacheSetGauge.Update(int64(stats.SetCalls))
398+
snapshotCacheMissGauge.Update(int64(stats.Misses))
399+
snapshotCacheSizeGauge.Update(int64(stats.BytesSize))
400+
snapshotCacheCapacityGauge.Update(int64(stats.MaxBytesSize))
401+
snapshotCacheEntriesGauge.Update(int64(stats.EntriesCount))
402+
snapshotCacheCollisionGauge.Update(int64(stats.Collisions))
403+
}
402404

403405
// If the generator is still running, use a more aggressive cap
404406
diff.origin.lock.RLock()

triedb/pathdb/disklayer.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -306,15 +306,17 @@ func (dl *diskLayer) update(root common.Hash, id uint64, block uint64, nodes *no
306306
// and returns a newly constructed disk layer. Note the current disk
307307
// layer must be tagged as stale first to prevent re-access.
308308
func (dl *diskLayer) commit(bottom *diffLayer, force bool) (*diskLayer, error) {
309-
var stats fastcache.Stats
310-
dl.nodes.UpdateStats(&stats)
311-
snapshotCacheGetGauge.Update(int64(stats.GetCalls))
312-
snapshotCacheSetGauge.Update(int64(stats.SetCalls))
313-
snapshotCacheMissGauge.Update(int64(stats.Misses))
314-
snapshotCacheSizeGauge.Update(int64(stats.BytesSize))
315-
snapshotCacheCapacityGauge.Update(int64(stats.MaxBytesSize))
316-
snapshotCacheEntriesGauge.Update(int64(stats.EntriesCount))
317-
snapshotCacheCollisionGauge.Update(int64(stats.Collisions))
309+
if dl.nodes != nil {
310+
var stats fastcache.Stats
311+
dl.nodes.UpdateStats(&stats)
312+
snapshotCacheGetGauge.Update(int64(stats.GetCalls))
313+
snapshotCacheSetGauge.Update(int64(stats.SetCalls))
314+
snapshotCacheMissGauge.Update(int64(stats.Misses))
315+
snapshotCacheSizeGauge.Update(int64(stats.BytesSize))
316+
snapshotCacheCapacityGauge.Update(int64(stats.MaxBytesSize))
317+
snapshotCacheEntriesGauge.Update(int64(stats.EntriesCount))
318+
snapshotCacheCollisionGauge.Update(int64(stats.Collisions))
319+
}
318320

319321
dl.lock.Lock()
320322
defer dl.lock.Unlock()

0 commit comments

Comments
 (0)