Skip to content

Commit c1fb64d

Browse files
committed
Address PR review comments
1 parent 94c8547 commit c1fb64d

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

core/state/snapshot/disklayer.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ func (dl *diskLayer) Stale() bool {
7676

7777
// Account directly retrieves the account associated with a particular hash in
7878
// the snapshot slim data format.
79-
func (dl *diskLayer) account(hash common.Hash, ignoreStale bool) (*types.SlimAccount, error) {
80-
data, err := dl.accountRLP(hash, ignoreStale)
79+
func (dl *diskLayer) account(hash common.Hash, evenIfStale bool) (*types.SlimAccount, error) {
80+
data, err := dl.accountRLP(hash, evenIfStale)
8181
if err != nil {
8282
return nil, err
8383
}
@@ -91,13 +91,13 @@ func (dl *diskLayer) account(hash common.Hash, ignoreStale bool) (*types.SlimAcc
9191

9292
// AccountRLP directly retrieves the account RLP associated with a particular
9393
// hash in the snapshot slim data format.
94-
func (dl *diskLayer) accountRLP(hash common.Hash, ignoreStale bool) ([]byte, error) {
94+
func (dl *diskLayer) accountRLP(hash common.Hash, evenIfStale bool) ([]byte, error) {
9595
dl.lock.RLock()
9696
defer dl.lock.RUnlock()
9797

9898
// If the layer was flattened into, consider it invalid (any live reference to
9999
// the original should be marked as unusable).
100-
if dl.stale && !ignoreStale {
100+
if dl.stale && !evenIfStale {
101101
return nil, ErrSnapshotStale
102102
}
103103
// If the layer is being generated, ensure the requested hash has already been

core/state/snapshot/snapshot.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,10 @@ func diffToDisk(bottom *diffLayer) *diskLayer {
568568
rawdb.DeleteAccountSnapshot(batch, hash)
569569
base.cache.Set(hash[:], nil)
570570

571-
if err == nil && (oldAccount == nil || oldAccount.Root == nil) {
571+
if err != nil {
572+
log.Warn("Failed to get destructed account from snapshot", "err", err)
573+
// Fall through to deleting storage in case this account has any
574+
} else if oldAccount == nil || oldAccount.Root == nil {
572575
// There's no storage associated with this account to delete
573576
continue
574577
}

0 commit comments

Comments
 (0)