formatting changes and lint

This commit is contained in:
shantichanal 2025-07-15 13:46:16 +02:00 committed by lightclient
parent ff0837ab29
commit 4acb3c46f6
No known key found for this signature in database
GPG key ID: 657913021EF45A6A
2 changed files with 11 additions and 23 deletions

View file

@ -55,7 +55,7 @@ const (
headerSize uint64 = 8 headerSize uint64 = 8
) )
type proofvar uint16 type variant uint16
type buffer struct { type buffer struct {
headers [][]byte headers [][]byte
@ -81,7 +81,7 @@ type Builder struct {
buff buffer buff buffer
off offsets off offsets
prooftype proofvar prooftype variant
tdsint []*big.Int tdsint []*big.Int
hashes []common.Hash hashes []common.Hash
startNum *uint64 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. // 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 { 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) pv := variantOf(proof) // variant code (or proofNone)
var ep []byte // encoded proof payload var ep []byte // encoded proof payload
if proof != nil { if proof != nil {
var buf bytes.Buffer var buf bytes.Buffer
@ -282,18 +282,6 @@ func (b *Builder) addEntry(typ uint16, payload []byte, snappyIt bool) (uint64, e
return offset, nil 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 // write index takes all the offset table and writes it to the file
// the index table contains all offsets to specific block entries // the index table contains all offsets to specific block entries
func (b *Builder) writeIndex() error { func (b *Builder) writeIndex() error {

View file

@ -22,7 +22,7 @@ type metadata struct {
} }
const ( const (
ProofNone proofvar = iota ProofNone variant = iota
proofHHA proofHHA
proofRoots proofRoots
proofCapella proofCapella
@ -66,7 +66,7 @@ type BlockProofHistoricalSummariesDeneb struct {
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() proofvar Variant() variant
} }
type hhaAlias BlockProofHistoricalHashesAccumulator // alias ⇒ no EncodeRLP method type hhaAlias BlockProofHistoricalHashesAccumulator // alias ⇒ no EncodeRLP method
@ -76,7 +76,7 @@ func (p *BlockProofHistoricalHashesAccumulator) EncodeRLP(w io.Writer) error {
return rlp.Encode(w, payload) return rlp.Encode(w, payload)
} }
func (p *BlockProofHistoricalHashesAccumulator) Variant() proofvar { return proofHHA } func (p *BlockProofHistoricalHashesAccumulator) Variant() variant { return proofHHA }
type rootsAlias BlockProofHistoricalRoots type rootsAlias BlockProofHistoricalRoots
@ -85,7 +85,7 @@ func (p *BlockProofHistoricalRoots) EncodeRLP(w io.Writer) error {
return rlp.Encode(w, payload) return rlp.Encode(w, payload)
} }
func (*BlockProofHistoricalRoots) Variant() proofvar { return proofRoots } func (*BlockProofHistoricalRoots) Variant() variant { return proofRoots }
type capellaAlias BlockProofHistoricalSummariesCapella type capellaAlias BlockProofHistoricalSummariesCapella
@ -94,7 +94,7 @@ func (p *BlockProofHistoricalSummariesCapella) EncodeRLP(w io.Writer) error {
return rlp.Encode(w, payload) return rlp.Encode(w, payload)
} }
func (*BlockProofHistoricalSummariesCapella) Variant() proofvar { return proofCapella } func (*BlockProofHistoricalSummariesCapella) Variant() variant { return proofCapella }
type denebAlias BlockProofHistoricalSummariesDeneb type denebAlias BlockProofHistoricalSummariesDeneb
@ -103,9 +103,9 @@ func (p *BlockProofHistoricalSummariesDeneb) EncodeRLP(w io.Writer) error {
return rlp.Encode(w, payload) 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 { if p == nil {
return ProofNone return ProofNone
} }