From 701f6aecbd35c5bc2172852f6c2a93e735bfbe72 Mon Sep 17 00:00:00 2001 From: devopsbo3 <69951731+devopsbo3@users.noreply.github.com> Date: Fri, 10 Nov 2023 12:27:53 -0600 Subject: [PATCH] Revert "core/rawdb: add logging and fix comments around AncientRange function. (#28379)" This reverts commit f81a9f3eda9818c78622d5cf33595ec5ae76d7a2. --- core/rawdb/accessors_chain.go | 19 +++++++------------ core/rawdb/freezer_resettable.go | 7 +++---- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/core/rawdb/accessors_chain.go b/core/rawdb/accessors_chain.go index d9a89fe90c..97401d283c 100644 --- a/core/rawdb/accessors_chain.go +++ b/core/rawdb/accessors_chain.go @@ -334,18 +334,13 @@ func ReadHeaderRange(db ethdb.Reader, number uint64, count uint64) []rlp.RawValu return rlpHeaders } // read remaining from ancients - data, err := db.AncientRange(ChainFreezerHeaderTable, i+1-count, count, 0) - if err != nil { - log.Error("Failed to read headers from freezer", "err", err) - return rlpHeaders - } - if uint64(len(data)) != count { - log.Warn("Incomplete read of headers from freezer", "wanted", count, "read", len(data)) - return rlpHeaders - } - // The data is on the order [h, h+1, .., n] -- reordering needed - for i := range data { - rlpHeaders = append(rlpHeaders, data[len(data)-1-i]) + max := count * 700 + data, err := db.AncientRange(ChainFreezerHeaderTable, i+1-count, count, max) + if err == nil && uint64(len(data)) == count { + // the data is on the order [h, h+1, .., n] -- reordering needed + for i := range data { + rlpHeaders = append(rlpHeaders, data[len(data)-1-i]) + } } return rlpHeaders } diff --git a/core/rawdb/freezer_resettable.go b/core/rawdb/freezer_resettable.go index 7a85489738..1df6411a39 100644 --- a/core/rawdb/freezer_resettable.go +++ b/core/rawdb/freezer_resettable.go @@ -119,10 +119,9 @@ func (f *ResettableFreezer) Ancient(kind string, number uint64) ([]byte, error) // AncientRange retrieves multiple items in sequence, starting from the index 'start'. // It will return -// - at most 'count' items, -// - if maxBytes is specified: at least 1 item (even if exceeding the maxByteSize), -// but will otherwise return as many items as fit into maxByteSize. -// - if maxBytes is not specified, 'count' items will be returned if they are present. +// - at most 'max' items, +// - at least 1 item (even if exceeding the maxByteSize), but will otherwise +// return as many items as fit into maxByteSize func (f *ResettableFreezer) AncientRange(kind string, start, count, maxBytes uint64) ([][]byte, error) { f.lock.RLock() defer f.lock.RUnlock()