Documentation
¶
Overview ¶
Copyright 2025 The go-ethereum Authors This file is part of the go-ethereum library.
The go-ethereum library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
The go-ethereum library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( TypeVersion uint16 = 0x3265 TypeCompressedHeader uint16 = 0x03 TypeCompressedBody uint16 = 0x04 TypeCompressedReceipts uint16 = 0x05 TypeTotalDifficulty uint16 = 0x06 TypeAccumulator uint16 = 0x07 TypeCompressedSlimReceipts uint16 = 0x0a // uses eth/69 encoding TypeProof uint16 = 0x0b TypeBlockIndex uint16 = 0x3266 TypeComponentIndex uint16 = 0x3267 MaxSize = 8192 )
Type constants for the e2store entries in the Era1 and EraE formats.
Functions ¶
func BigToBytes32 ¶ added in v1.17.0
bigToBytes32 converts a big.Int into a little-endian 32-byte array.
func ComputeAccumulator ¶
ComputeAccumulator calculates the SSZ hash tree root of the Era1 accumulator of header records.
Types ¶
type Builder ¶
type Builder interface {
// Add appends a block and its receipts to the era file.
// For pre-merge blocks, td must be provided.
// For post-merge blocks, td should be nil.
Add(block *types.Block, receipts types.Receipts, td *big.Int) error
// AddRLP appends RLP-encoded block components to the era file.
// For pre-merge blocks, td and difficulty must be provided.
// For post-merge blocks, td and difficulty should be nil.
AddRLP(header, body, receipts []byte, number uint64, hash common.Hash, td, difficulty *big.Int) error
// Finalize writes all collected entries and returns the epoch identifier.
// For Era1 (onedb): returns the accumulator root.
// For EraE (execdb): returns the last block hash.
Finalize() (common.Hash, error)
// Accumulator returns the accumulator root after Finalize has been called.
// Returns nil for post-merge epochs where no accumulator exists.
Accumulator() *common.Hash
}
Builder constructs era files from blocks and receipts.
Builders handle three epoch types automatically:
- Pre-merge: all blocks have difficulty > 0, TD is stored for each block
- Transition: starts pre-merge, ends post-merge; TD stored for all blocks
- Post-merge: all blocks have difficulty == 0, no TD stored
type Era ¶
type Era interface {
Close() error
Start() uint64
Count() uint64
Iterator() (Iterator, error)
GetBlockByNumber(num uint64) (*types.Block, error)
GetRawBodyByNumber(num uint64) ([]byte, error)
GetRawReceiptsByNumber(num uint64) ([]byte, error)
InitialTD() (*big.Int, error)
Accumulator() (common.Hash, error)
}
Era represents the interface for reading era data.
type Iterator ¶
type Iterator interface {
// Next advances to the next block. Returns true if a block is available,
// false when iteration is complete or an error occurred.
Next() bool
// Number returns the block number of the current block.
Number() uint64
// Block returns the current block.
Block() (*types.Block, error)
// BlockAndReceipts returns the current block and its receipts.
BlockAndReceipts() (*types.Block, types.Receipts, error)
// Receipts returns the receipts for the current block.
Receipts() (types.Receipts, error)
// Error returns any error encountered during iteration.
Error() error
}
Iterator provides sequential access to blocks in an era file.
type Proof ¶ added in v1.17.0
type Proof interface {
EncodeRLP(w io.Writer) error
DecodeRLP(s *rlp.Stream) error
Variant() ProofVariant
}
Proof is the interface for all block proof types in the package. It's a stub for later integration into Era.
type ProofVariant ¶ added in v1.17.0
type ProofVariant uint16
const (
ProofNone ProofVariant = iota
)