core/rawdb: use help functions on ancients

This commit is contained in:
lightclient 2025-05-29 14:19:54 -06:00
parent 102bd99560
commit 809f2e140f
No known key found for this signature in database
GPG key ID: 657913021EF45A6A

View file

@ -193,7 +193,7 @@ func (f *chainFreezer) freeze(db ethdb.KeyValueStore) {
log.Debug("Current full block not old enough to freeze", "err", err)
continue
}
frozen, _ := f.ancients.Ancients() // no error will occur, safe to ignore
frozen, _ := f.Ancients() // no error will occur, safe to ignore
// Short circuit if the blocks below threshold are already frozen.
if frozen != 0 && frozen-1 >= threshold {
@ -236,7 +236,7 @@ func (f *chainFreezer) freeze(db ethdb.KeyValueStore) {
// Wipe out side chains also and track dangling side chains
var dangling []common.Hash
frozen, _ = f.ancients.Ancients() // Needs reload after during freezeRange
frozen, _ = f.Ancients() // Needs reload after during freezeRange
for number := first; number < frozen; number++ {
// Always keep the genesis block in active database
if number != 0 {
@ -308,7 +308,7 @@ func (f *chainFreezer) freeze(db ethdb.KeyValueStore) {
func (f *chainFreezer) freezeRange(nfdb *nofreezedb, number, limit uint64) (hashes []common.Hash, err error) {
hashes = make([]common.Hash, 0, limit-number+1)
_, err = f.ancients.ModifyAncients(func(op ethdb.AncientWriteOp) error {
_, err = f.ModifyAncients(func(op ethdb.AncientWriteOp) error {
for ; number <= limit; number++ {
// Retrieve all the components of the canonical block.
hash := ReadCanonicalHash(nfdb, number)