From 2a4e159d205ba633e7d4760cf935af3b93120c6c Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi Date: Thu, 10 Apr 2025 11:48:31 +0200 Subject: [PATCH] glob for network --- core/rawdb/eradb/eradb.go | 7 +++---- core/rawdb/eradb/eradb_test.go | 2 +- core/rawdb/freezer.go | 3 ++- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/rawdb/eradb/eradb.go b/core/rawdb/eradb/eradb.go index 60c8898585..340d5556af 100644 --- a/core/rawdb/eradb/eradb.go +++ b/core/rawdb/eradb/eradb.go @@ -30,13 +30,12 @@ import ( type EraDatabase struct { datadir string - network string // TODO: should take into account configured number of fd handles. cache *lru.Cache[uint64, *era.Era] } // New creates a new EraDatabase instance. -func New(datadir, network string) (*EraDatabase, error) { +func New(datadir string) (*EraDatabase, error) { // Ensure the datadir is not a symbolic link if it exists. if info, err := os.Lstat(datadir); !os.IsNotExist(err) { if info == nil { @@ -51,7 +50,7 @@ func New(datadir, network string) (*EraDatabase, error) { if err := os.MkdirAll(datadir, 0755); err != nil { return nil, err } - db := &EraDatabase{datadir: datadir, network: network, cache: lru.NewCache[uint64, *era.Era](50)} + db := &EraDatabase{datadir: datadir, cache: lru.NewCache[uint64, *era.Era](50)} log.Info("Opened erastore", "datadir", datadir) return db, nil } @@ -77,7 +76,7 @@ func (db *EraDatabase) getEraByEpoch(epoch uint64) (*era.Era, error) { return e, nil } // file name scheme is --. - glob := fmt.Sprintf("%s-%05d-*.era1", db.network, epoch) + glob := fmt.Sprintf("*-%05d-*.era1", epoch) matches, err := filepath.Glob(filepath.Join(db.datadir, glob)) if err != nil { return nil, err diff --git a/core/rawdb/eradb/eradb_test.go b/core/rawdb/eradb/eradb_test.go index 7163f06cea..47cc4119eb 100644 --- a/core/rawdb/eradb/eradb_test.go +++ b/core/rawdb/eradb/eradb_test.go @@ -24,7 +24,7 @@ import ( func TestEraDatabase(t *testing.T) { // Create the database - db, err := New("testdata", "sepolia") + db, err := New("testdata") require.NoError(t, err) defer db.Close() diff --git a/core/rawdb/freezer.go b/core/rawdb/freezer.go index 92e237943e..28c01e729c 100644 --- a/core/rawdb/freezer.go +++ b/core/rawdb/freezer.go @@ -125,7 +125,8 @@ func NewFreezer(datadir string, namespace string, readonly bool, maxTableSize ui // Create the era database. // TODO: Pipe down network name. - edb, err := eradb.New(datadir, "sepolia") + eradir := filepath.Join(datadir, "eradb") + edb, err := eradb.New(eradir) if err != nil { lock.Unlock() return nil, err