Documentation ¶
Index ¶
- Variables
- func ComputeAccumulator(hashes [][]byte, tds []*big.Int) ([]byte, error)
- func Filename(epoch int, network string) string
- type Builder
- type Reader
- func (r *Reader) Accumulator() ([]byte, error)
- func (r *Reader) Close() error
- func (r *Reader) Count() (uint64, error)
- func (r *Reader) Read() ([]byte, []byte, error)
- func (r *Reader) ReadBlock(n uint64) ([]byte, error)
- func (r *Reader) ReadBlockAndReceipts(n uint64) ([]byte, []byte, error)
- func (r *Reader) Start() (uint64, error)
- func (r *Reader) TotalDifficulty() (*big.Int, error)
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func ComputeAccumulator ¶
ComputeAccumulator calculates the SSZ hash tree root of the Era accumulator of header records.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder is used to create Era archives of block data.
Era files are themselves e2store files. For more information on this format, see https://github.com/status-im/nimbus-eth2/blob/stable/docs/e2store.md.
The overall structure of an Era file can be summarized with this definition:
era := Version | block-tuple* | other-entries* | Accumulator | StartTD | BlockIndex block-tuple := CompressedBlock | CompressedReceipts
Each basic element is its own entry:
Version = { type: [0x65, 0x32], data: nil } CompressedBlock = { type: [0x03, 0x00], data: snappyFramed(rlp(block)) } CompressedReceipts = { type: [0x04, 0x00], data: snappyFramed(rlp(receipts)) } Accumulator = { type: [0x05, 0x00], data: hash_tree_root(blockHashes, 8192) } StartTD = { type: [0x06, 0x00], data: uint256(startingTotalDifficulty) } BlockIndex = { type: [0x32, 0x66], data: block-index }
BlockIndex stores relative offsets to each compressed block entry. The format is:
block-index := starting-number | index | index | index ... | count
starting-number is the first block number in the archive. Every index is a defined relative to index's location in the file. The total number of block entries in the file is recorded in count.
Due to the accumulator size limit of 8192, the maximum number of blocks in an Era batch is also 8192.
func NewBuilder ¶
NewBuilder returns a new Builder instance. start is the first block number in the Era and td is the total difficulty of the chain before the first block is applied.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader reads an Era archive. See Builder documentation for a detailed explanation of the Era format.
func NewReader ¶
func NewReader(r io.ReadSeekCloser) *Reader
NewReader returns a new Reader instance.
func (*Reader) Accumulator ¶
Accumulator reads the accumulator entry in the Era file.
func (*Reader) ReadBlock ¶
ReadBlock reads the block number n from the Era archive. The method returns error if the Era file is malformed, the request is out-of-bounds, as determined by the block index, or if the block number at the calculated offset doesn't match the requested.
func (*Reader) ReadBlockAndReceipts ¶
The method returns error if the Era file is malformed, the request is out-of-bounds, as determined by the block index, or if the block number at the calculated offset doesn't match the requested.