diff --git a/opera/genesisstore/disk.go b/opera/genesisstore/disk.go index e9116ceda..4919eb1e3 100644 --- a/opera/genesisstore/disk.go +++ b/opera/genesisstore/disk.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "io" + "strings" "time" "github.com/Fantom-foundation/lachesis-base/common/bigendian" @@ -133,14 +134,19 @@ func OpenGenesisStore(rawReader ReadAtSeekerCloser) (*Store, genesis.Hashes, err // wrap with a logger // human-readable name name := unit.UnitName - if unit.UnitName == BlocksSection { - name = "blocks" + scanfName := strings.ReplaceAll(name, "-", "") + if scanfName[len(scanfName)-1] < '0' || scanfName[len(scanfName)-1] > '9' { + scanfName += "0" } - if unit.UnitName == EpochsSection { - name = "epochs" + var part int + if _, err := fmt.Sscanf(scanfName, "brs%d", &part); err == nil { + name = fmt.Sprintf("blocks unit %d", part) } - if unit.UnitName == EvmSection { - name = "EVM data" + if _, err := fmt.Sscanf(scanfName, "ers%d", &part); err == nil { + name = fmt.Sprintf("epochs unit %d", part) + } + if _, err := fmt.Sscanf(scanfName, "evm%d", &part); err == nil { + name = fmt.Sprintf("EVM unit %d", part) } loggedReader := filelog.Wrap(gzipReader, name, uncompressedSize, time.Minute) diff --git a/opera/genesisstore/store_genesis.go b/opera/genesisstore/store_genesis.go index aa78bc7a1..ff2079fdb 100644 --- a/opera/genesisstore/store_genesis.go +++ b/opera/genesisstore/store_genesis.go @@ -38,7 +38,7 @@ func getSectionName(base string, i int) string { if i == 0 { return base } - return fmt.Sprintf("%s-%d", BlocksSection, i) + return fmt.Sprintf("%s-%d", base, i) } func (s Store) Header() genesis.Header { @@ -50,10 +50,10 @@ func (s *Store) Blocks() genesis.Blocks { } func (s Blocks) ForEach(fn func(ibr.LlrIdxFullBlockRecord) bool) { - for i := 0; ; i++ { + for i := 1000; i >= 0; i-- { f, err := s.fMap(getSectionName(BlocksSection, i)) if err != nil { - return + continue } stream := rlp.NewStream(f, 0) for { @@ -77,10 +77,10 @@ func (s *Store) Epochs() genesis.Epochs { } func (s Epochs) ForEach(fn func(ier.LlrIdxFullEpochRecord) bool) { - for i := 0; ; i++ { + for i := 1000; i >= 0; i-- { f, err := s.fMap(getSectionName(EpochsSection, i)) if err != nil { - return + continue } stream := rlp.NewStream(f, 0) for { @@ -104,10 +104,10 @@ func (s *Store) RawEvmItems() genesis.EvmItems { } func (s RawEvmItems) ForEach(fn func(key, value []byte) bool) { - for i := 0; ; i++ { + for i := 1000; i >= 0; i-- { f, err := s.fMap(getSectionName(EvmSection, i)) if err != nil { - return + continue } it := iodb.NewIterator(f) for it.Next() {