touch-ups

This commit is contained in:
Sina Mahmoodi 2026-02-02 13:09:12 +01:00
parent 223b5bcff4
commit eda6bc43ec
3 changed files with 6 additions and 5 deletions

View file

@ -114,7 +114,7 @@ type Era interface {
Accumulator() (common.Hash, error) Accumulator() (common.Hash, error)
} }
// ReadDir reads all the era1 files in a directory for a given network. // ReadDir reads all the era files in a directory for a given network.
// Format: <network>-<epoch>-<hexroot>.erae or <network>-<epoch>-<hexroot>.era1 // Format: <network>-<epoch>-<hexroot>.erae or <network>-<epoch>-<hexroot>.era1
func ReadDir(dir, network string) ([]string, error) { func ReadDir(dir, network string) ([]string, error) {
entries, err := os.ReadDir(dir) entries, err := os.ReadDir(dir)
@ -137,7 +137,7 @@ func ReadDir(dir, network string) ([]string, error) {
} }
parts := strings.Split(entry.Name(), "-") parts := strings.Split(entry.Name(), "-")
if len(parts) != 3 || parts[0] != network { if len(parts) != 3 || parts[0] != network {
// Invalid era1 filename, skip. // Invalid era filename, skip.
continue continue
} }
if epoch, err := strconv.ParseUint(parts[1], 10, 64); err != nil { if epoch, err := strconv.ParseUint(parts[1], 10, 64); err != nil {

View file

@ -251,6 +251,7 @@ func (e *Era) headerOff(num uint64) (int64, error) { return e.indexOffset(num,
func (e *Era) bodyOff(num uint64) (int64, error) { return e.indexOffset(num, body) } func (e *Era) bodyOff(num uint64) (int64, error) { return e.indexOffset(num, body) }
func (e *Era) receiptOff(num uint64) (int64, error) { return e.indexOffset(num, receipts) } func (e *Era) receiptOff(num uint64) (int64, error) { return e.indexOffset(num, receipts) }
func (e *Era) tdOff(num uint64) (int64, error) { return e.indexOffset(num, td) } func (e *Era) tdOff(num uint64) (int64, error) { return e.indexOffset(num, td) }
func (e *Era) proofOff(num uint64) (int64, error) { return e.indexOffset(num, proof) }
// indexOffset calculates offset to a certain component for a block number within a file. // indexOffset calculates offset to a certain component for a block number within a file.
func (e *Era) indexOffset(n uint64, component componentType) (int64, error) { func (e *Era) indexOffset(n uint64, component componentType) (int64, error) {
@ -286,7 +287,7 @@ type metadata struct {
// componentType represents the integer form of a specific type that can be present in the era file. // componentType represents the integer form of a specific type that can be present in the era file.
type componentType int type componentType int
// TypeCompressedHeader, TypeCompressedBody, TypeCompressedReceipts, TypeTotalDifficulty, and TypeProof are the different types of components that can be present in the era file. // header, body, receipts, td, and proof are the different types of components that can be present in the era file.
const ( const (
header componentType = iota header componentType = iota
body body

View file

@ -27,10 +27,10 @@ const (
ProofNone ProofVariant = iota ProofNone ProofVariant = iota
) )
// Proof is the interface for all block proof types in the package. // Proof is the interface for all block proof types in the package.
// It's a stub for later integration into Era. // It's a stub for later integration into Era.
type Proof interface { type Proof interface {
EncodeRLP(w io.Writer) error EncodeRLP(w io.Writer) error
DecodeRlP(s *rlp.Stream) error DecodeRLP(s *rlp.Stream) error
Variant() ProofVariant Variant() ProofVariant
} }