From 4acb3c46f6236df81966cb040f6bf384341e8664 Mon Sep 17 00:00:00 2001 From: shantichanal <158101918+shantichanal@users.noreply.github.com> Date: Tue, 15 Jul 2025 13:46:16 +0200 Subject: [PATCH] formatting changes and lint --- internal/era2/builder.go | 20 ++++---------------- internal/era2/era.go | 14 +++++++------- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/internal/era2/builder.go b/internal/era2/builder.go index 42ee727d37..a291174121 100644 --- a/internal/era2/builder.go +++ b/internal/era2/builder.go @@ -55,7 +55,7 @@ const ( headerSize uint64 = 8 ) -type proofvar uint16 +type variant uint16 type buffer struct { headers [][]byte @@ -81,7 +81,7 @@ type Builder struct { buff buffer off offsets - prooftype proofvar + prooftype variant tdsint []*big.Int hashes []common.Hash startNum *uint64 @@ -100,8 +100,8 @@ func NewBuilder(w io.Writer) *Builder { // Add writes a block entry, its reciepts, and optionally its proofs as well into the e2store file. func (b *Builder) Add(header types.Header, body types.Body, receipts types.Receipts, td *big.Int, proof Proof) error { - pv := proofVariantOf(proof) // variant code (or proofNone) - var ep []byte // encoded proof payload + pv := variantOf(proof) // variant code (or proofNone) + var ep []byte // encoded proof payload if proof != nil { var buf bytes.Buffer @@ -282,18 +282,6 @@ func (b *Builder) addEntry(typ uint16, payload []byte, snappyIt bool) (uint64, e return offset, nil } -// flush kind takes all entries of the cached component and flushes it to the file -func (b *Builder) flushKind(typ uint16, list [][]byte, useSnappy bool, dst *[]uint64) error { - for _, data := range list { - off, err := b.addEntry(typ, data, useSnappy) - if err != nil { - return fmt.Errorf("entry type %d: %w", typ, err) - } - *dst = append(*dst, off) - } - return nil -} - // write index takes all the offset table and writes it to the file // the index table contains all offsets to specific block entries func (b *Builder) writeIndex() error { diff --git a/internal/era2/era.go b/internal/era2/era.go index 233d4417a4..85e711b5a1 100644 --- a/internal/era2/era.go +++ b/internal/era2/era.go @@ -22,7 +22,7 @@ type metadata struct { } const ( - ProofNone proofvar = iota + ProofNone variant = iota proofHHA proofRoots proofCapella @@ -66,7 +66,7 @@ type BlockProofHistoricalSummariesDeneb struct { type Proof interface { EncodeRLP(w io.Writer) error DecodeRlP(s *rlp.Stream) error - Variant() proofvar + Variant() variant } type hhaAlias BlockProofHistoricalHashesAccumulator // alias ⇒ no EncodeRLP method @@ -76,7 +76,7 @@ func (p *BlockProofHistoricalHashesAccumulator) EncodeRLP(w io.Writer) error { return rlp.Encode(w, payload) } -func (p *BlockProofHistoricalHashesAccumulator) Variant() proofvar { return proofHHA } +func (p *BlockProofHistoricalHashesAccumulator) Variant() variant { return proofHHA } type rootsAlias BlockProofHistoricalRoots @@ -85,7 +85,7 @@ func (p *BlockProofHistoricalRoots) EncodeRLP(w io.Writer) error { return rlp.Encode(w, payload) } -func (*BlockProofHistoricalRoots) Variant() proofvar { return proofRoots } +func (*BlockProofHistoricalRoots) Variant() variant { return proofRoots } type capellaAlias BlockProofHistoricalSummariesCapella @@ -94,7 +94,7 @@ func (p *BlockProofHistoricalSummariesCapella) EncodeRLP(w io.Writer) error { return rlp.Encode(w, payload) } -func (*BlockProofHistoricalSummariesCapella) Variant() proofvar { return proofCapella } +func (*BlockProofHistoricalSummariesCapella) Variant() variant { return proofCapella } type denebAlias BlockProofHistoricalSummariesDeneb @@ -103,9 +103,9 @@ func (p *BlockProofHistoricalSummariesDeneb) EncodeRLP(w io.Writer) error { return rlp.Encode(w, payload) } -func (*BlockProofHistoricalSummariesDeneb) Variant() proofvar { return proofDeneb } +func (*BlockProofHistoricalSummariesDeneb) Variant() variant { return proofDeneb } -func proofVariantOf(p Proof) proofvar { +func variantOf(p Proof) variant { if p == nil { return ProofNone }