freezeblocks

package
v0.0.0-...-1f8a15b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2023 License: GPL-3.0 Imports: 58 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyTxHash = common2.Hash{}
View Source
var MergeSteps = []uint64{500_000, 100_000, 10_000}
View Source
var RecentMergeSteps = []uint64{100_000, 10_000}

Functions

func BeaconBlocksIdx

func BeaconBlocksIdx(ctx context.Context, sn snaptype.FileInfo, segmentFilePath string, blockFrom, blockTo uint64, tmpDir string, p *background.Progress, lvl log.Lvl, logger log.Logger) (err error)

func BodiesIdx

func BodiesIdx(ctx context.Context, segmentFilePath string, firstBlockNumInSegment uint64, tmpDir string, p *background.Progress, lvl log.Lvl, logger log.Logger) (err error)

func BorEventsIdx

func BorEventsIdx(ctx context.Context, segmentFilePath string, blockFrom, blockTo uint64, snapDir string, tmpDir string, p *background.Progress, lvl log.Lvl, logger log.Logger) (err error)

func BorSpansIdx

func BorSpansIdx(ctx context.Context, segmentFilePath string, blockFrom, blockTo uint64, snapDir string, tmpDir string, p *background.Progress, lvl log.Lvl, logger log.Logger) (err error)

func BuildBorMissedIndices

func BuildBorMissedIndices(logPrefix string, ctx context.Context, dirs datadir.Dirs, chainConfig *chain.Config, workers int, logger log.Logger) error

func BuildMissedIndices

func BuildMissedIndices(logPrefix string, ctx context.Context, dirs datadir.Dirs, chainConfig *chain.Config, workers int, logger log.Logger) error

func CanDeleteTo

func CanDeleteTo(curBlockNum uint64, blocksInSnapshots uint64) (blockTo uint64)

func CanRetire

func CanRetire(curBlockNum uint64, blocksInSnapshots uint64) (blockFrom, blockTo uint64, can bool)

func DumpBeaconBlocks

func DumpBeaconBlocks(ctx context.Context, db kv.RoDB, b persistence.BlockSource, fromSlot, toSlot, blocksPerFile uint64, tmpDir, snapDir string, workers int, lvl log.Lvl, logger log.Logger) error

func DumpBlocks

func DumpBlocks(ctx context.Context, blockFrom, blockTo, blocksPerFile uint64, tmpDir, snapDir string, firstTxNum uint64, chainDB kv.RoDB, workers int, lvl log.Lvl, logger log.Logger, blockReader services.FullBlockReader) error

func DumpBodies

func DumpBodies(ctx context.Context, db kv.RoDB, blockFrom, blockTo uint64, firstTxNum uint64, workers int, lvl log.Lvl, logger log.Logger, collect func([]byte) error) error

DumpBodies - [from, to)

func DumpBorBlocks

func DumpBorBlocks(ctx context.Context, chainConfig *chain.Config, blockFrom, blockTo, blocksPerFile uint64, tmpDir, snapDir string, firstTxNum uint64, chainDB kv.RoDB, workers int, lvl log.Lvl, logger log.Logger, blockReader services.FullBlockReader) error

func DumpBorEvents

func DumpBorEvents(ctx context.Context, db kv.RoDB, blockFrom, blockTo uint64, workers int, lvl log.Lvl, logger log.Logger, collect func([]byte) error) error

DumpBorEvents - [from, to)

func DumpBorSpans

func DumpBorSpans(ctx context.Context, db kv.RoDB, blockFrom, blockTo uint64, workers int, lvl log.Lvl, logger log.Logger, collect func([]byte) error) error

DumpBorSpans - [from, to)

func DumpHeaders

func DumpHeaders(ctx context.Context, db kv.RoDB, blockFrom, blockTo uint64, workers int, lvl log.Lvl, logger log.Logger, collect func([]byte) error) error

DumpHeaders - [from, to)

func DumpTxs

func DumpTxs(ctx context.Context, db kv.RoDB, blockFrom, blockTo uint64, chainConfig *chain.Config, workers int, lvl log.Lvl, logger log.Logger, collect func([]byte) error) (expectedCount int, err error)

DumpTxs - [from, to) Format: hash[0]_1byte + sender_address_2bytes + txnRlp

func ForEachHeader

func ForEachHeader(ctx context.Context, s *RoSnapshots, walker func(header *types.Header) error) error

func HeadersIdx

func HeadersIdx(ctx context.Context, chainConfig *chain.Config, segmentFilePath string, firstBlockNumInSegment uint64, tmpDir string, p *background.Progress, lvl log.Lvl, logger log.Logger) (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, logger log.Logger) error

Idx - iterate over segment and building .idx file

func TransactionsIdx

func TransactionsIdx(ctx context.Context, chainConfig *chain.Config, blockFrom, blockTo uint64, snapDir string, tmpDir string, p *background.Progress, lvl log.Lvl, logger log.Logger) (err error)

Types

type BeaconBlockSegment

type BeaconBlockSegment struct {
	// contains filtered or unexported fields
}

type BeaconSnapshotReader

type BeaconSnapshotReader interface {
	// ReadBlock reads the block at the given slot.
	// If the block is not present, it returns nil.
	ReadBlockBySlot(ctx context.Context, tx kv.Tx, slot uint64) (*cltypes.SignedBeaconBlock, error)
	ReadBlockByRoot(ctx context.Context, tx kv.Tx, blockRoot libcommon.Hash) (*cltypes.SignedBeaconBlock, error)
	ReadHeaderByRoot(ctx context.Context, tx kv.Tx, blockRoot libcommon.Hash) (*cltypes.SignedBeaconBlockHeader, error)

	FrozenSlots() uint64
}

type BlockReader

type BlockReader struct {
	// contains filtered or unexported fields
}

BlockReader can read blocks from db and snapshots

func NewBlockReader

func NewBlockReader(snapshots services.BlockSnapshots, borSnapshots services.BlockSnapshots) *BlockReader

func (*BlockReader) BadHeaderNumber

func (r *BlockReader) BadHeaderNumber(ctx context.Context, tx kv.Getter, hash common.Hash) (blockHeight *uint64, err error)

func (*BlockReader) BlockByHash

func (r *BlockReader) BlockByHash(ctx context.Context, db kv.Tx, hash common.Hash) (*types.Block, error)

func (*BlockReader) BlockByNumber

func (r *BlockReader) BlockByNumber(ctx context.Context, db kv.Tx, number uint64) (*types.Block, error)

func (*BlockReader) BlockWithSenders

func (r *BlockReader) BlockWithSenders(ctx context.Context, tx kv.Getter, hash common.Hash, blockHeight uint64) (block *types.Block, senders []common.Address, err error)

func (*BlockReader) Body

func (r *BlockReader) Body(ctx context.Context, tx kv.Getter, hash common.Hash, blockHeight uint64) (body *types.Body, txAmount uint32, err error)

func (*BlockReader) BodyRlp

func (r *BlockReader) BodyRlp(ctx context.Context, tx kv.Getter, hash common.Hash, blockHeight uint64) (bodyRlp rlp.RawValue, err error)

func (*BlockReader) BodyWithTransactions

func (r *BlockReader) BodyWithTransactions(ctx context.Context, tx kv.Getter, hash common.Hash, blockHeight uint64) (body *types.Body, err error)

func (*BlockReader) BorSnapshots

func (r *BlockReader) BorSnapshots() services.BlockSnapshots

func (*BlockReader) CanPruneTo

func (r *BlockReader) CanPruneTo(currentBlockInDB uint64) uint64

func (*BlockReader) CanonicalHash

func (r *BlockReader) CanonicalHash(ctx context.Context, tx kv.Getter, blockHeight uint64) (h common.Hash, err error)

func (*BlockReader) CurrentBlock

func (r *BlockReader) CurrentBlock(db kv.Tx) (*types.Block, error)

func (*BlockReader) EventLookup

func (r *BlockReader) EventLookup(ctx context.Context, tx kv.Getter, txnHash common.Hash) (uint64, bool, error)

func (*BlockReader) EventsByBlock

func (r *BlockReader) EventsByBlock(ctx context.Context, tx kv.Tx, hash common.Hash, blockHeight uint64) ([]rlp.RawValue, error)

func (*BlockReader) FirstTxNumNotInSnapshots

func (r *BlockReader) FirstTxNumNotInSnapshots() uint64

func (*BlockReader) FreezingCfg

func (r *BlockReader) FreezingCfg() ethconfig.BlocksFreezing

func (*BlockReader) FrozenBlocks

func (r *BlockReader) FrozenBlocks() uint64

func (*BlockReader) FrozenBorBlocks

func (r *BlockReader) FrozenBorBlocks() uint64

func (*BlockReader) FrozenFiles

func (r *BlockReader) FrozenFiles() []string

func (*BlockReader) HasSenders

func (r *BlockReader) HasSenders(ctx context.Context, tx kv.Getter, hash common.Hash, blockHeight uint64) (bool, error)

func (*BlockReader) Header

func (r *BlockReader) Header(ctx context.Context, tx kv.Getter, hash common.Hash, blockHeight uint64) (h *types.Header, err error)

func (*BlockReader) HeaderByHash

func (r *BlockReader) HeaderByHash(ctx context.Context, tx kv.Getter, hash common.Hash) (h *types.Header, err error)

HeaderByHash - will search header in all snapshots starting from recent

func (*BlockReader) HeaderByNumber

func (r *BlockReader) HeaderByNumber(ctx context.Context, tx kv.Getter, blockHeight uint64) (h *types.Header, err error)

func (*BlockReader) HeadersRange

func (r *BlockReader) HeadersRange(ctx context.Context, walker func(header *types.Header) error) error

func (*BlockReader) Integrity

func (r *BlockReader) Integrity(ctx context.Context) error

func (*BlockReader) IterateFrozenBodies

func (r *BlockReader) IterateFrozenBodies(f func(blockNum, baseTxNum, txAmount uint64) error) error

func (*BlockReader) LastFrozenEventID

func (r *BlockReader) LastFrozenEventID() uint64

func (*BlockReader) LastFrozenSpanID

func (r *BlockReader) LastFrozenSpanID() uint64

func (*BlockReader) RawTransactions

func (r *BlockReader) RawTransactions(ctx context.Context, tx kv.Getter, fromBlock, toBlock uint64) (txs [][]byte, err error)

func (*BlockReader) ReadAncestor

func (r *BlockReader) ReadAncestor(db kv.Getter, hash common.Hash, number, ancestor uint64, maxNonCanonical *uint64) (common.Hash, uint64)

func (*BlockReader) Snapshots

func (r *BlockReader) Snapshots() services.BlockSnapshots

func (*BlockReader) Span

func (r *BlockReader) Span(ctx context.Context, tx kv.Getter, spanId uint64) ([]byte, error)

func (*BlockReader) TxnByIdxInBlock

func (r *BlockReader) TxnByIdxInBlock(ctx context.Context, tx kv.Getter, blockNum uint64, txIdxInBlock 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 (*BlockReader) TxnLookup

func (r *BlockReader) TxnLookup(ctx context.Context, tx kv.Getter, txnHash common.Hash) (uint64, bool, error)

TxnLookup - find blockNumber and txnID by txnHash

type BlockRetire

type BlockRetire struct {
	// contains filtered or unexported fields
}

func NewBlockRetire

func NewBlockRetire(workers int, dirs datadir.Dirs, blockReader services.FullBlockReader, blockWriter *blockio.BlockWriter, db kv.RoDB, notifier services.DBEventNotifier, logger log.Logger) *BlockRetire

func (*BlockRetire) BuildMissedIndicesIfNeed

func (br *BlockRetire) BuildMissedIndicesIfNeed(ctx context.Context, logPrefix string, notifier services.DBEventNotifier, cc *chain.Config) error

func (*BlockRetire) HasNewFrozenFiles

func (br *BlockRetire) HasNewFrozenFiles() bool

func (*BlockRetire) PruneAncientBlocks

func (br *BlockRetire) PruneAncientBlocks(tx kv.RwTx, limit int, includeBor bool) error

func (*BlockRetire) RetireBlocks

func (br *BlockRetire) RetireBlocks(ctx context.Context, blockFrom, blockTo uint64, lvl log.Lvl, seedNewSnapshots func(downloadRequest []services.DownloadRequest) error, onDelete func(l []string) error) error

func (*BlockRetire) RetireBlocksInBackground

func (br *BlockRetire) RetireBlocksInBackground(ctx context.Context, forwardProgress uint64, includeBor bool, lvl log.Lvl, seedNewSnapshots func(downloadRequest []services.DownloadRequest) error, onDeleteSnapshots func(l []string) error)

func (*BlockRetire) RetireBorBlocks

func (br *BlockRetire) RetireBorBlocks(ctx context.Context, blockFrom, blockTo uint64, lvl log.Lvl, seedNewSnapshots func(downloadRequest []services.DownloadRequest) error, onDelete func(l []string) error) error

type BodySegment

type BodySegment struct {
	// contains filtered or unexported fields
}

type BorEventSegment

type BorEventSegment struct {
	IdxBorTxnHash *recsplit.Index // bor_transaction_hash  -> bor_event_segment_offset
	// contains filtered or unexported fields
}

type BorMerger

type BorMerger struct {
	// contains filtered or unexported fields
}

func NewBorMerger

func NewBorMerger(tmpDir string, compressWorkers int, lvl log.Lvl, chainDB kv.RoDB, chainConfig *chain.Config, notifier services.DBEventNotifier, logger log.Logger) *BorMerger

func (*BorMerger) FindMergeRanges

func (m *BorMerger) FindMergeRanges(currentRanges []Range, maxBlockNum uint64) (toMerge []Range)

func (*BorMerger) Merge

func (m *BorMerger) Merge(ctx context.Context, snapshots *BorRoSnapshots, mergeRanges []Range, snapDir string, doIndex bool, onMerge func(r Range) error, onDelete func(l []string) error) error

Merge does merge segments in given ranges

type BorRoSnapshots

type BorRoSnapshots struct {
	Events *borEventSegments
	Spans  *borSpanSegments
	// contains filtered or unexported fields
}

func NewBorRoSnapshots

func NewBorRoSnapshots(cfg ethconfig.BlocksFreezing, snapDir string, logger log.Logger) *BorRoSnapshots

NewBorRoSnapshots - opens all bor 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 (*BorRoSnapshots) BlocksAvailable

func (s *BorRoSnapshots) BlocksAvailable() uint64

func (*BorRoSnapshots) Cfg

func (*BorRoSnapshots) Close

func (s *BorRoSnapshots) Close()

func (*BorRoSnapshots) Dir

func (s *BorRoSnapshots) Dir() string

func (*BorRoSnapshots) DisableReadAhead

func (s *BorRoSnapshots) DisableReadAhead()

DisableReadAhead - usage: `defer d.EnableReadAhead().DisableReadAhead()`. Please don't use this funcs without `defer` to avoid leak.

func (*BorRoSnapshots) EnableMadvNormal

func (s *BorRoSnapshots) EnableMadvNormal() *BorRoSnapshots

func (*BorRoSnapshots) EnableMadvWillNeed

func (s *BorRoSnapshots) EnableMadvWillNeed() *BorRoSnapshots

func (*BorRoSnapshots) EnableReadAhead

func (s *BorRoSnapshots) EnableReadAhead() *BorRoSnapshots

func (*BorRoSnapshots) EnsureExpectedBlocksAreAvailable

func (s *BorRoSnapshots) EnsureExpectedBlocksAreAvailable(cfg *snapcfg.Cfg) error

func (*BorRoSnapshots) Files

func (s *BorRoSnapshots) Files() (list []string)

func (*BorRoSnapshots) IndicesMax

func (s *BorRoSnapshots) IndicesMax() uint64

func (*BorRoSnapshots) IndicesReady

func (s *BorRoSnapshots) IndicesReady() bool

func (*BorRoSnapshots) LogStat

func (s *BorRoSnapshots) LogStat()

func (*BorRoSnapshots) OptimisticReopenWithDB

func (s *BorRoSnapshots) 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 (*BorRoSnapshots) OptimisticalyReopenFolder

func (s *BorRoSnapshots) OptimisticalyReopenFolder()

func (*BorRoSnapshots) OptimisticalyReopenWithDB

func (s *BorRoSnapshots) OptimisticalyReopenWithDB(db kv.RoDB)

func (*BorRoSnapshots) PrintDebug

func (s *BorRoSnapshots) PrintDebug()

func (*BorRoSnapshots) Ranges

func (s *BorRoSnapshots) Ranges() (ranges []Range)

func (*BorRoSnapshots) ReopenFolder

func (s *BorRoSnapshots) ReopenFolder() error

func (*BorRoSnapshots) ReopenList

func (s *BorRoSnapshots) ReopenList(fileNames []string, optimistic bool) error

ReopenList stops on optimistic=false, continue opening files on optimistic=true

func (*BorRoSnapshots) ReopenWithDB

func (s *BorRoSnapshots) ReopenWithDB(db kv.RoDB) error

func (*BorRoSnapshots) ScanDir

func (s *BorRoSnapshots) ScanDir() (map[string]struct{}, []*services.Range, error)

func (*BorRoSnapshots) SegmentsMax

func (s *BorRoSnapshots) SegmentsMax() uint64

func (*BorRoSnapshots) SegmentsReady

func (s *BorRoSnapshots) SegmentsReady() bool

func (*BorRoSnapshots) View

func (s *BorRoSnapshots) View() *BorView

type BorSpanSegment

type BorSpanSegment struct {
	// contains filtered or unexported fields
}

type BorView

type BorView struct {
	// contains filtered or unexported fields
}

func (*BorView) Close

func (v *BorView) Close()

func (*BorView) Events

func (v *BorView) Events() []*BorEventSegment

func (*BorView) EventsSegment

func (v *BorView) EventsSegment(blockNum uint64) (*BorEventSegment, bool)

func (*BorView) Spans

func (v *BorView) Spans() []*BorSpanSegment

func (*BorView) SpansSegment

func (v *BorView) SpansSegment(blockNum uint64) (*BorSpanSegment, bool)

type CaplinSnapshots

type CaplinSnapshots struct {
	BeaconBlocks *beaconBlockSegments
	// contains filtered or unexported fields
}

func NewCaplinSnapshots

func NewCaplinSnapshots(cfg ethconfig.BlocksFreezing, snapDir string, logger log.Logger) *CaplinSnapshots

NewCaplinSnapshots - 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 (*CaplinSnapshots) BlocksAvailable

func (s *CaplinSnapshots) BlocksAvailable() uint64

func (*CaplinSnapshots) BuildMissingIndices

func (s *CaplinSnapshots) BuildMissingIndices(ctx context.Context, logger log.Logger, lvl log.Lvl) error

func (*CaplinSnapshots) IndicesMax

func (s *CaplinSnapshots) IndicesMax() uint64

func (*CaplinSnapshots) ReadHeader

func (*CaplinSnapshots) ReopenFolder

func (s *CaplinSnapshots) ReopenFolder() error

func (*CaplinSnapshots) ReopenList

func (s *CaplinSnapshots) ReopenList(fileNames []string, optimistic bool) error

ReopenList stops on optimistic=false, continue opening files on optimistic=true

func (*CaplinSnapshots) SegFilePaths

func (s *CaplinSnapshots) SegFilePaths(from, to uint64) []string

func (*CaplinSnapshots) SegmentsMax

func (s *CaplinSnapshots) SegmentsMax() uint64

func (*CaplinSnapshots) View

func (s *CaplinSnapshots) View() *CaplinView

type CaplinView

type CaplinView struct {
	// contains filtered or unexported fields
}

func (*CaplinView) BeaconBlocks

func (v *CaplinView) BeaconBlocks() []*BeaconBlockSegment

func (*CaplinView) BeaconBlocksSegment

func (v *CaplinView) BeaconBlocksSegment(slot uint64) (*BeaconBlockSegment, bool)

func (*CaplinView) Close

func (v *CaplinView) Close()

type HeaderSegment

type HeaderSegment struct {
	// contains filtered or unexported fields
}

type Merger

type Merger struct {
	// contains filtered or unexported fields
}

func NewMerger

func NewMerger(tmpDir string, compressWorkers int, lvl log.Lvl, chainDB kv.RoDB, chainConfig *chain.Config, logger log.Logger) *Merger

func (*Merger) FindMergeRanges

func (m *Merger) FindMergeRanges(currentRanges []Range, maxBlockNum uint64) (toMerge []Range)

func (*Merger) Merge

func (m *Merger) Merge(ctx context.Context, snapshots *RoSnapshots, mergeRanges []Range, snapDir string, doIndex bool, onMerge func(r Range) error, onDelete func(l []string) error) error

Merge does merge segments in given ranges

type Range

type Range struct {
	// contains filtered or unexported fields
}

func BorSegments

func BorSegments(dir string) (res []snaptype.FileInfo, missingSnapshots []Range, err error)

func Segments

func Segments(dir string) (res []snaptype.FileInfo, missingSnapshots []Range, err error)

func SegmentsCaplin

func SegmentsCaplin(dir string) (res []snaptype.FileInfo, missingSnapshots []Range, err error)

func (Range) From

func (r Range) From() uint64

func (Range) IsRecent

func (r Range) IsRecent(max uint64) bool

func (Range) To

func (r Range) To() uint64

type Ranges

type Ranges []Range

func (Ranges) String

func (r Ranges) String() string

type RemoteBlockReader

type RemoteBlockReader struct {
	// contains filtered or unexported fields
}

func NewRemoteBlockReader

func NewRemoteBlockReader(client remote.ETHBACKENDClient) *RemoteBlockReader

func (*RemoteBlockReader) BadHeaderNumber

func (r *RemoteBlockReader) BadHeaderNumber(ctx context.Context, tx kv.Getter, hash common.Hash) (blockHeight *uint64, err error)

func (*RemoteBlockReader) BlockByHash

func (r *RemoteBlockReader) BlockByHash(ctx context.Context, db kv.Tx, hash common.Hash) (*types.Block, error)

func (*RemoteBlockReader) BlockByNumber

func (r *RemoteBlockReader) BlockByNumber(ctx context.Context, db kv.Tx, number uint64) (*types.Block, error)

func (*RemoteBlockReader) BlockWithSenders

func (r *RemoteBlockReader) BlockWithSenders(ctx context.Context, _ kv.Getter, hash common.Hash, blockHeight uint64) (block *types.Block, senders []common.Address, err error)

func (*RemoteBlockReader) Body

func (r *RemoteBlockReader) Body(ctx context.Context, tx kv.Getter, hash common.Hash, blockHeight uint64) (body *types.Body, txAmount uint32, err error)

func (*RemoteBlockReader) BodyRlp

func (r *RemoteBlockReader) BodyRlp(ctx context.Context, tx kv.Getter, hash common.Hash, blockHeight uint64) (bodyRlp rlp.RawValue, err error)

func (*RemoteBlockReader) BodyWithTransactions

func (r *RemoteBlockReader) BodyWithTransactions(ctx context.Context, tx kv.Getter, hash common.Hash, blockHeight uint64) (body *types.Body, err error)

func (*RemoteBlockReader) BorSnapshots

func (r *RemoteBlockReader) BorSnapshots() services.BlockSnapshots

func (*RemoteBlockReader) CanPruneTo

func (r *RemoteBlockReader) CanPruneTo(uint64) uint64

func (*RemoteBlockReader) CanonicalHash

func (r *RemoteBlockReader) CanonicalHash(ctx context.Context, tx kv.Getter, blockHeight uint64) (common.Hash, error)

func (*RemoteBlockReader) CurrentBlock

func (r *RemoteBlockReader) CurrentBlock(db kv.Tx) (*types.Block, error)

func (*RemoteBlockReader) EventLookup

func (r *RemoteBlockReader) EventLookup(ctx context.Context, tx kv.Getter, txnHash common.Hash) (uint64, bool, error)

func (*RemoteBlockReader) EventsByBlock

func (r *RemoteBlockReader) EventsByBlock(ctx context.Context, tx kv.Tx, hash common.Hash, blockHeight uint64) ([]rlp.RawValue, error)

func (*RemoteBlockReader) FreezingCfg

func (r *RemoteBlockReader) FreezingCfg() ethconfig.BlocksFreezing

func (*RemoteBlockReader) FrozenBlocks

func (r *RemoteBlockReader) FrozenBlocks() uint64

func (*RemoteBlockReader) FrozenBorBlocks

func (r *RemoteBlockReader) FrozenBorBlocks() uint64

func (*RemoteBlockReader) FrozenFiles

func (r *RemoteBlockReader) FrozenFiles() (list []string)

func (*RemoteBlockReader) HasSenders

func (r *RemoteBlockReader) HasSenders(ctx context.Context, _ kv.Getter, hash common.Hash, blockHeight uint64) (bool, error)

func (*RemoteBlockReader) Header

func (r *RemoteBlockReader) Header(ctx context.Context, tx kv.Getter, hash common.Hash, blockHeight uint64) (*types.Header, error)

func (*RemoteBlockReader) HeaderByHash

func (r *RemoteBlockReader) HeaderByHash(ctx context.Context, tx kv.Getter, hash common.Hash) (*types.Header, error)

func (*RemoteBlockReader) HeaderByNumber

func (r *RemoteBlockReader) HeaderByNumber(ctx context.Context, tx kv.Getter, blockHeight uint64) (*types.Header, error)

func (*RemoteBlockReader) HeadersRange

func (r *RemoteBlockReader) HeadersRange(ctx context.Context, walker func(header *types.Header) error) error

func (*RemoteBlockReader) RawTransactions

func (r *RemoteBlockReader) RawTransactions(ctx context.Context, tx kv.Getter, fromBlock, toBlock uint64) (txs [][]byte, err error)

func (*RemoteBlockReader) ReadAncestor

func (r *RemoteBlockReader) ReadAncestor(db kv.Getter, hash common.Hash, number, ancestor uint64, maxNonCanonical *uint64) (common.Hash, uint64)

func (*RemoteBlockReader) Snapshots

func (r *RemoteBlockReader) Snapshots() services.BlockSnapshots

func (*RemoteBlockReader) Span

func (r *RemoteBlockReader) Span(ctx context.Context, tx kv.Getter, spanId uint64) ([]byte, error)

func (*RemoteBlockReader) TxnByIdxInBlock

func (r *RemoteBlockReader) TxnByIdxInBlock(ctx context.Context, tx kv.Getter, blockNum uint64, i int) (txn types.Transaction, err error)

func (*RemoteBlockReader) TxnLookup

func (r *RemoteBlockReader) TxnLookup(ctx context.Context, tx kv.Getter, txnHash common.Hash) (uint64, bool, error)

type RoSnapshots

type RoSnapshots struct {
	Headers *headerSegments
	Bodies  *bodySegments
	Txs     *txnSegments
	// contains filtered or unexported fields
}

func NewRoSnapshots

func NewRoSnapshots(cfg ethconfig.BlocksFreezing, snapDir string, logger log.Logger) *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) AddSnapshotsToSilkworm

func (s *RoSnapshots) AddSnapshotsToSilkworm(silkwormInstance *silkworm.Silkworm) error

func (*RoSnapshots) BlocksAvailable

func (s *RoSnapshots) BlocksAvailable() uint64

func (*RoSnapshots) Cfg

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) ScanDir

func (s *RoSnapshots) ScanDir() (map[string]struct{}, []*services.Range, error)

func (*RoSnapshots) SegmentsMax

func (s *RoSnapshots) SegmentsMax() uint64

func (*RoSnapshots) SegmentsReady

func (s *RoSnapshots) SegmentsReady() bool

func (*RoSnapshots) View

func (s *RoSnapshots) View() *View

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
}

type View

type View struct {
	// contains filtered or unexported fields
}

func (*View) Bodies

func (v *View) Bodies() []*BodySegment

func (*View) BodiesSegment

func (v *View) BodiesSegment(blockNum uint64) (*BodySegment, bool)

func (*View) Close

func (v *View) Close()

func (*View) Headers

func (v *View) Headers() []*HeaderSegment

func (*View) HeadersSegment

func (v *View) HeadersSegment(blockNum uint64) (*HeaderSegment, bool)

func (*View) Txs

func (v *View) Txs() []*TxnSegment

func (*View) TxsSegment

func (v *View) TxsSegment(blockNum uint64) (*TxnSegment, bool)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL