From 477bbf1d1817a1b18607f0b0ea4ee392e9156442 Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi Date: Thu, 15 May 2025 16:26:18 +0200 Subject: [PATCH] fixes --- core/rawdb/chain_freezer.go | 14 ++++++++++++++ core/rawdb/eradb/eradb.go | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/core/rawdb/chain_freezer.go b/core/rawdb/chain_freezer.go index f20a5e0aa7..d293ceab97 100644 --- a/core/rawdb/chain_freezer.go +++ b/core/rawdb/chain_freezer.go @@ -380,3 +380,17 @@ func (f *chainFreezer) Ancient(kind string, number uint64) ([]byte, error) { } return nil, errUnknownTable } + +// 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. +func (f *chainFreezer) ReadAncients(fn func(ethdb.AncientReaderOp) error) (err error) { + if store, ok := f.AncientStore.(*Freezer); ok { + store.writeLock.Lock() + defer store.writeLock.Unlock() + } + return fn(f) +} diff --git a/core/rawdb/eradb/eradb.go b/core/rawdb/eradb/eradb.go index 0f0976deb5..ec793cac3a 100644 --- a/core/rawdb/eradb/eradb.go +++ b/core/rawdb/eradb/eradb.go @@ -232,7 +232,7 @@ func (db *Store) openEraFile(epoch uint64) (*era.Era, error) { return nil, fmt.Errorf("multiple era1 files found for epoch %d", epoch) } if len(matches) == 0 { - return nil, nil + return nil, fs.ErrNotExist } filename := matches[0]