mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
trie/triedb/pathdb: fix initialization flaws
This commit is contained in:
parent
435bed5da0
commit
8d22d9a3b3
2 changed files with 7 additions and 2 deletions
|
|
@ -431,6 +431,9 @@ func (db *Database) Initialized(genesisRoot common.Hash) bool {
|
||||||
inited = true
|
inited = true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
if !inited {
|
||||||
|
inited = rawdb.ReadSnapSyncStatusFlag(db.diskdb) != rawdb.StateSyncUnknown
|
||||||
|
}
|
||||||
return inited
|
return inited
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -576,8 +576,10 @@ func truncateFromHead(db ethdb.Batcher, freezer *rawdb.ResettableFreezer, nhead
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
// Ensure that the truncation target falls within the specified range.
|
// Ensure that the truncation target falls within the specified range.
|
||||||
if ohead < nhead || nhead < otail {
|
if nhead != 0 { // truncating to zero is always possible
|
||||||
return 0, fmt.Errorf("out of range, tail: %d, head: %d, target: %d", otail, ohead, nhead)
|
if ohead < nhead || nhead < otail {
|
||||||
|
return 0, fmt.Errorf("out of range, tail: %d, head: %d, target: %d", otail, ohead, nhead)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Short circuit if nothing to truncate.
|
// Short circuit if nothing to truncate.
|
||||||
if ohead == nhead {
|
if ohead == nhead {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue