Documentation ¶
Index ¶
- Variables
- func BodiesIdx(ctx context.Context, segmentFilePath string, firstBlockNumInSegment uint64, ...) (err error)
- func BuildMissedIndices(logPrefix string, ctx context.Context, dirs datadir.Dirs, chainID uint256.Int, ...) error
- func BuildProtoRequest(downloadRequest []DownloadRequest) *proto_downloader.DownloadRequest
- func CanDeleteTo(curBlockNum uint64, snapshots *RoSnapshots) (blockTo uint64)
- func CanRetire(curBlockNum uint64, snapshots *RoSnapshots) (blockFrom, blockTo uint64, can bool)
- func DumpBlocks(ctx context.Context, blockFrom, blockTo, blocksPerFile uint64, ...) error
- func DumpBodies(ctx context.Context, db kv.RoDB, segmentFilePath, tmpDir string, ...) error
- func DumpHeaders(ctx context.Context, db kv.RoDB, segmentFilePath, tmpDir string, ...) error
- func DumpTxs(ctx context.Context, db kv.RoDB, segmentFile, tmpDir string, ...) (firstTxID uint64, err error)
- func ForEachHeader(ctx context.Context, s *RoSnapshots, walker func(header *types.Header) error) error
- func HeadersIdx(ctx context.Context, segmentFilePath string, firstBlockNumInSegment uint64, ...) (err error)
- func Idx(ctx context.Context, d *compress.Decompressor, firstDataID uint64, ...) error
- func RequestSnapshotsDownload(ctx context.Context, downloadRequest []DownloadRequest, ...) error
- func TransactionsIdx(ctx context.Context, chainID uint256.Int, blockFrom, blockTo uint64, ...) (err error)
- type BackgroundResult
- type BlockReaderWithSnapshots
- func (back *BlockReaderWithSnapshots) BlockWithSenders(ctx context.Context, tx kv.Getter, hash libcommon.Hash, blockHeight uint64) (block *types.Block, senders []libcommon.Address, err error)
- func (back *BlockReaderWithSnapshots) Body(ctx context.Context, tx kv.Getter, hash libcommon.Hash, blockHeight uint64) (body *types.Body, txAmount uint32, err error)
- func (back *BlockReaderWithSnapshots) BodyRlp(ctx context.Context, tx kv.Getter, hash libcommon.Hash, blockHeight uint64) (bodyRlp rlp.RawValue, err error)
- func (back *BlockReaderWithSnapshots) BodyWithTransactions(ctx context.Context, tx kv.Getter, hash libcommon.Hash, blockHeight uint64) (body *types.Body, err error)
- func (back *BlockReaderWithSnapshots) CanonicalHash(ctx context.Context, tx kv.Getter, blockHeight uint64) (h libcommon.Hash, err error)
- func (back *BlockReaderWithSnapshots) Header(ctx context.Context, tx kv.Getter, hash libcommon.Hash, blockHeight uint64) (h *types.Header, err error)
- func (back *BlockReaderWithSnapshots) HeaderByHash(ctx context.Context, tx kv.Getter, hash libcommon.Hash) (h *types.Header, err error)
- func (back *BlockReaderWithSnapshots) HeaderByNumber(ctx context.Context, tx kv.Getter, blockHeight uint64) (h *types.Header, err error)
- func (back *BlockReaderWithSnapshots) Snapshots() *RoSnapshots
- func (back *BlockReaderWithSnapshots) TxnByIdxInBlock(ctx context.Context, tx kv.Getter, blockNum uint64, i int) (txn types.Transaction, err error)
- func (back *BlockReaderWithSnapshots) TxnEffectiveGasPricePercentage(ctx context.Context, tx kv.Tx, txnHash libcommon.Hash) (uint8, error)
- func (back *BlockReaderWithSnapshots) TxnLookup(ctx context.Context, tx kv.Getter, txnHash libcommon.Hash) (uint64, bool, error)
- type BlockRetire
- func (br *BlockRetire) NeedSaveFilesListInDB() bool
- func (br *BlockRetire) PruneAncientBlocks(tx kv.RwTx, limit int) error
- func (br *BlockRetire) RetireBlocks(ctx context.Context, blockFrom, blockTo uint64, lvl log.Lvl) error
- func (br *BlockRetire) RetireBlocksInBackground(ctx context.Context, forwardProgress uint64, lvl log.Lvl)
- func (br *BlockRetire) Snapshots() *RoSnapshots
- type BodiesIterator
- type BodySegment
- type DBEventNotifier
- type DownloadRequest
- type HeaderSegment
- type Merger
- type Range
- type RemoteBlockReader
- func (back *RemoteBlockReader) BlockWithSenders(ctx context.Context, _ kv.Getter, hash libcommon.Hash, blockHeight uint64) (block *types.Block, senders []libcommon.Address, err error)
- func (back *RemoteBlockReader) Body(ctx context.Context, tx kv.Getter, hash libcommon.Hash, blockHeight uint64) (body *types.Body, txAmount uint32, err error)
- func (back *RemoteBlockReader) BodyRlp(ctx context.Context, tx kv.Getter, hash libcommon.Hash, blockHeight uint64) (bodyRlp rlp.RawValue, err error)
- func (back *RemoteBlockReader) BodyWithTransactions(ctx context.Context, tx kv.Getter, hash libcommon.Hash, blockHeight uint64) (body *types.Body, err error)
- func (back *RemoteBlockReader) CanonicalHash(ctx context.Context, tx kv.Getter, blockHeight uint64) (libcommon.Hash, error)
- func (back *RemoteBlockReader) Header(ctx context.Context, tx kv.Getter, hash libcommon.Hash, blockHeight uint64) (*types.Header, error)
- func (back *RemoteBlockReader) HeaderByHash(ctx context.Context, tx kv.Getter, hash libcommon.Hash) (*types.Header, error)
- func (back *RemoteBlockReader) HeaderByNumber(ctx context.Context, tx kv.Getter, blockHeight uint64) (*types.Header, error)
- func (back *RemoteBlockReader) Snapshots() *RoSnapshots
- func (back *RemoteBlockReader) TxnByIdxInBlock(ctx context.Context, tx kv.Getter, blockNum uint64, i int) (txn types.Transaction, err error)
- func (back *RemoteBlockReader) TxnEffectiveGasPricePercentage(ctx context.Context, tx kv.Tx, txnHash libcommon.Hash) (uint8, error)
- func (back *RemoteBlockReader) TxnLookup(ctx context.Context, tx kv.Getter, txnHash libcommon.Hash) (uint64, bool, error)
- type RoSnapshots
- func (s *RoSnapshots) BlocksAvailable() uint64
- func (s *RoSnapshots) Cfg() ethconfig.Snapshot
- func (s *RoSnapshots) Close()
- func (s *RoSnapshots) Dir() string
- func (s *RoSnapshots) DisableReadAhead()
- func (s *RoSnapshots) EnableMadvNormal() *RoSnapshots
- func (s *RoSnapshots) EnableMadvWillNeed() *RoSnapshots
- func (s *RoSnapshots) EnableReadAhead() *RoSnapshots
- func (s *RoSnapshots) EnsureExpectedBlocksAreAvailable(cfg *snapcfg.Cfg) error
- func (s *RoSnapshots) Files() (list []string)
- func (s *RoSnapshots) IndicesMax() uint64
- func (s *RoSnapshots) IndicesReady() bool
- func (s *RoSnapshots) LogStat()
- func (s *RoSnapshots) OptimisticReopenWithDB(db kv.RoDB)
- func (s *RoSnapshots) OptimisticalyReopenFolder()
- func (s *RoSnapshots) OptimisticalyReopenWithDB(db kv.RoDB)
- func (s *RoSnapshots) PrintDebug()
- func (s *RoSnapshots) Ranges() (ranges []Range)
- func (s *RoSnapshots) ReopenFolder() error
- func (s *RoSnapshots) ReopenList(fileNames []string, optimistic bool) error
- func (s *RoSnapshots) ReopenWithDB(db kv.RoDB) error
- func (s *RoSnapshots) SegmentsMax() uint64
- func (s *RoSnapshots) SegmentsReady() bool
- func (s *RoSnapshots) ViewBodies(blockNum uint64, f func(sn *BodySegment) error) (found bool, err error)
- func (s *RoSnapshots) ViewHeaders(blockNum uint64, f func(sn *HeaderSegment) error) (found bool, err error)
- func (s *RoSnapshots) ViewTxs(blockNum uint64, f func(sn *TxnSegment) error) (found bool, err error)
- type TxnSegment
Constants ¶
This section is empty.
Variables ¶
var EmptyTxHash = common2.Hash{}
Functions ¶
func BuildMissedIndices ¶
func BuildProtoRequest ¶
func BuildProtoRequest(downloadRequest []DownloadRequest) *proto_downloader.DownloadRequest
func CanDeleteTo ¶
func CanDeleteTo(curBlockNum uint64, snapshots *RoSnapshots) (blockTo uint64)
func CanRetire ¶
func CanRetire(curBlockNum uint64, snapshots *RoSnapshots) (blockFrom, blockTo uint64, can bool)
func DumpBlocks ¶
func DumpBodies ¶
func DumpBodies(ctx context.Context, db kv.RoDB, segmentFilePath, tmpDir string, blockFrom, blockTo uint64, workers int, lvl log.Lvl) error
DumpBodies - [from, to)
func DumpHeaders ¶
func DumpHeaders(ctx context.Context, db kv.RoDB, segmentFilePath, tmpDir string, blockFrom, blockTo uint64, workers int, lvl log.Lvl) error
DumpHeaders - [from, to)
func DumpTxs ¶
func DumpTxs(ctx context.Context, db kv.RoDB, segmentFile, tmpDir string, blockFrom, blockTo uint64, workers int, lvl log.Lvl) (firstTxID uint64, err error)
DumpTxs - [from, to) Format: hash[0]_1byte + sender_address_2bytes + txnRlp
func ForEachHeader ¶
func HeadersIdx ¶
func HeadersIdx(ctx context.Context, segmentFilePath string, firstBlockNumInSegment uint64, tmpDir string, p *background.Progress, lvl log.Lvl) (err error)
HeadersIdx - headerHash -> offset (analog of kv.HeaderNumber)
func Idx ¶
func Idx(ctx context.Context, d *compress.Decompressor, firstDataID uint64, tmpDir string, lvl log.Lvl, walker func(idx *recsplit.RecSplit, i, offset uint64, word []byte) error) error
Idx - iterate over segment and building .idx file
func RequestSnapshotsDownload ¶
func RequestSnapshotsDownload(ctx context.Context, downloadRequest []DownloadRequest, downloader proto_downloader.DownloaderClient) error
RequestSnapshotsDownload - builds the snapshots download request and downloads them
Types ¶
type BackgroundResult ¶
type BackgroundResult struct {
// contains filtered or unexported fields
}
BackgroundResult - used only indicate that some work is done no much reason to pass exact results by this object, just get latest state when need
func (*BackgroundResult) GetAndReset ¶
func (br *BackgroundResult) GetAndReset() (bool, error)
func (*BackgroundResult) Has ¶
func (br *BackgroundResult) Has() bool
func (*BackgroundResult) Set ¶
func (br *BackgroundResult) Set(err error)
type BlockReaderWithSnapshots ¶
type BlockReaderWithSnapshots struct { TransactionsV3 bool // contains filtered or unexported fields }
BlockReaderWithSnapshots can read blocks from db and snapshots
func NewBlockReaderWithSnapshots ¶
func NewBlockReaderWithSnapshots(snapshots *RoSnapshots, transactionsV3 bool) *BlockReaderWithSnapshots
func (*BlockReaderWithSnapshots) BlockWithSenders ¶
func (*BlockReaderWithSnapshots) BodyWithTransactions ¶
func (*BlockReaderWithSnapshots) CanonicalHash ¶
func (*BlockReaderWithSnapshots) HeaderByHash ¶
func (back *BlockReaderWithSnapshots) HeaderByHash(ctx context.Context, tx kv.Getter, hash libcommon.Hash) (h *types.Header, err error)
HeaderByHash - will search header in all snapshots starting from recent
func (*BlockReaderWithSnapshots) HeaderByNumber ¶
func (*BlockReaderWithSnapshots) Snapshots ¶
func (back *BlockReaderWithSnapshots) Snapshots() *RoSnapshots
func (*BlockReaderWithSnapshots) TxnByIdxInBlock ¶
func (back *BlockReaderWithSnapshots) TxnByIdxInBlock(ctx context.Context, tx kv.Getter, blockNum uint64, i int) (txn types.Transaction, err error)
TxnByIdxInBlock - doesn't include system-transactions in the begin/end of block return nil if 0 < i < body.TxAmount
func (*BlockReaderWithSnapshots) TxnEffectiveGasPricePercentage ¶
type BlockRetire ¶
type BlockRetire struct {
// contains filtered or unexported fields
}
func NewBlockRetire ¶
func NewBlockRetire(workers int, tmpDir string, snapshots *RoSnapshots, db kv.RoDB, downloader proto_downloader.DownloaderClient, notifier DBEventNotifier) *BlockRetire
func (*BlockRetire) NeedSaveFilesListInDB ¶
func (br *BlockRetire) NeedSaveFilesListInDB() bool
func (*BlockRetire) PruneAncientBlocks ¶
func (br *BlockRetire) PruneAncientBlocks(tx kv.RwTx, limit int) error
func (*BlockRetire) RetireBlocks ¶
func (br *BlockRetire) RetireBlocks(ctx context.Context, blockFrom, blockTo uint64, lvl log.Lvl) error
func (*BlockRetire) RetireBlocksInBackground ¶
func (br *BlockRetire) RetireBlocksInBackground(ctx context.Context, forwardProgress uint64, lvl log.Lvl)
func (*BlockRetire) Snapshots ¶
func (br *BlockRetire) Snapshots() *RoSnapshots
type BodiesIterator ¶
type BodiesIterator struct{}
type BodySegment ¶
type BodySegment struct {
// contains filtered or unexported fields
}
type DBEventNotifier ¶
type DBEventNotifier interface {
OnNewSnapshot()
}
type DownloadRequest ¶
type DownloadRequest struct {
// contains filtered or unexported fields
}
func NewDownloadRequest ¶
func NewDownloadRequest(ranges *Range, path string, torrentHash string) DownloadRequest
type HeaderSegment ¶
type HeaderSegment struct {
// contains filtered or unexported fields
}
type Merger ¶
type Merger struct {
// contains filtered or unexported fields
}
func (*Merger) FindMergeRanges ¶
type RemoteBlockReader ¶
type RemoteBlockReader struct {
// contains filtered or unexported fields
}
func NewRemoteBlockReader ¶
func NewRemoteBlockReader(client remote.ETHBACKENDClient) *RemoteBlockReader
func (*RemoteBlockReader) BlockWithSenders ¶
func (*RemoteBlockReader) BodyWithTransactions ¶
func (*RemoteBlockReader) CanonicalHash ¶
func (*RemoteBlockReader) HeaderByHash ¶
func (*RemoteBlockReader) HeaderByNumber ¶
func (*RemoteBlockReader) Snapshots ¶
func (back *RemoteBlockReader) Snapshots() *RoSnapshots
func (*RemoteBlockReader) TxnByIdxInBlock ¶
func (back *RemoteBlockReader) TxnByIdxInBlock(ctx context.Context, tx kv.Getter, blockNum uint64, i int) (txn types.Transaction, err error)
func (*RemoteBlockReader) TxnEffectiveGasPricePercentage ¶
type RoSnapshots ¶
type RoSnapshots struct { Headers *headerSegments Bodies *bodySegments Txs *txnSegments // contains filtered or unexported fields }
func NewRoSnapshots ¶
func NewRoSnapshots(cfg ethconfig.Snapshot, snapDir string) *RoSnapshots
NewRoSnapshots - opens all snapshots. But to simplify everything:
- it opens snapshots only on App start and immutable after
- all snapshots of given blocks range must exist - to make this blocks range available
- gaps are not allowed
- segment have [from:to) semantic
func (*RoSnapshots) BlocksAvailable ¶
func (s *RoSnapshots) BlocksAvailable() uint64
func (*RoSnapshots) Cfg ¶
func (s *RoSnapshots) Cfg() ethconfig.Snapshot
func (*RoSnapshots) Close ¶
func (s *RoSnapshots) Close()
func (*RoSnapshots) Dir ¶
func (s *RoSnapshots) Dir() string
func (*RoSnapshots) DisableReadAhead ¶
func (s *RoSnapshots) DisableReadAhead()
DisableReadAhead - usage: `defer d.EnableReadAhead().DisableReadAhead()`. Please don't use this funcs without `defer` to avoid leak.
func (*RoSnapshots) EnableMadvNormal ¶
func (s *RoSnapshots) EnableMadvNormal() *RoSnapshots
func (*RoSnapshots) EnableMadvWillNeed ¶
func (s *RoSnapshots) EnableMadvWillNeed() *RoSnapshots
func (*RoSnapshots) EnableReadAhead ¶
func (s *RoSnapshots) EnableReadAhead() *RoSnapshots
func (*RoSnapshots) EnsureExpectedBlocksAreAvailable ¶
func (s *RoSnapshots) EnsureExpectedBlocksAreAvailable(cfg *snapcfg.Cfg) error
func (*RoSnapshots) Files ¶
func (s *RoSnapshots) Files() (list []string)
func (*RoSnapshots) IndicesMax ¶
func (s *RoSnapshots) IndicesMax() uint64
func (*RoSnapshots) IndicesReady ¶
func (s *RoSnapshots) IndicesReady() bool
func (*RoSnapshots) LogStat ¶
func (s *RoSnapshots) LogStat()
func (*RoSnapshots) OptimisticReopenWithDB ¶
func (s *RoSnapshots) OptimisticReopenWithDB(db kv.RoDB)
OptimisticReopenWithDB - optimistically open snapshots (ignoring error), useful at App startup because: - user must be able: delete any snapshot file and Erigon will self-heal by re-downloading - RPC return Nil for historical blocks if snapshots are not open
func (*RoSnapshots) OptimisticalyReopenFolder ¶
func (s *RoSnapshots) OptimisticalyReopenFolder()
func (*RoSnapshots) OptimisticalyReopenWithDB ¶
func (s *RoSnapshots) OptimisticalyReopenWithDB(db kv.RoDB)
func (*RoSnapshots) PrintDebug ¶
func (s *RoSnapshots) PrintDebug()
func (*RoSnapshots) Ranges ¶
func (s *RoSnapshots) Ranges() (ranges []Range)
func (*RoSnapshots) ReopenFolder ¶
func (s *RoSnapshots) ReopenFolder() error
func (*RoSnapshots) ReopenList ¶
func (s *RoSnapshots) ReopenList(fileNames []string, optimistic bool) error
ReopenList stops on optimistic=false, continue opening files on optimistic=true
func (*RoSnapshots) ReopenWithDB ¶
func (s *RoSnapshots) ReopenWithDB(db kv.RoDB) error
func (*RoSnapshots) SegmentsMax ¶
func (s *RoSnapshots) SegmentsMax() uint64
func (*RoSnapshots) SegmentsReady ¶
func (s *RoSnapshots) SegmentsReady() bool
func (*RoSnapshots) ViewBodies ¶
func (s *RoSnapshots) ViewBodies(blockNum uint64, f func(sn *BodySegment) error) (found bool, err error)
func (*RoSnapshots) ViewHeaders ¶
func (s *RoSnapshots) ViewHeaders(blockNum uint64, f func(sn *HeaderSegment) error) (found bool, err error)
func (*RoSnapshots) ViewTxs ¶
func (s *RoSnapshots) ViewTxs(blockNum uint64, f func(sn *TxnSegment) error) (found bool, err error)
type TxnSegment ¶
type TxnSegment struct { Seg *compress.Decompressor // value: first_byte_of_transaction_hash + sender_address + transaction_rlp IdxTxnHash *recsplit.Index // transaction_hash -> transactions_segment_offset IdxTxnHash2BlockNum *recsplit.Index // transaction_hash -> block_number // contains filtered or unexported fields }