backfill

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package backfill is used to get logs from previous blocks

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContractBackfiller

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

ContractBackfiller is a backfiller that fetches logs for a specific contract.

func NewContractBackfiller

func NewContractBackfiller(contract contracts.DeployedContract, eventDB db.EventDB, client client.EVMClient) (*ContractBackfiller, error)

NewContractBackfiller creates a new backfiller for a contract.

func (ContractBackfiller) Backfill added in v0.0.2

func (c ContractBackfiller) Backfill(ctx context.Context, givenStart uint64, endHeight uint64) error

Backfill takes in a channel of logs, uses each log to get the receipt from its txHash, gets all of the logs from the receipt, then stores the receipt, the logs from the receipt, and the last indexed block for hte contract in the EventDB.

func (ContractBackfiller) GetLogs

func (c ContractBackfiller) GetLogs(ctx context.Context, startHeight, endHeight uint64) (logsChan <-chan types.Log, errsChan <-chan error, completeChan <-chan bool)

GetLogs gets all logs for the contract.

func (ContractBackfiller) StartHeightForBackfill

func (c ContractBackfiller) StartHeightForBackfill(ctx context.Context, givenStart uint64) (startHeight uint64, err error)

StartHeightForBackfill gets the startHeight for backfilling. This is the maximum of the most recent block for the contract and the startHeight given in the config.

func (ContractBackfiller) Store added in v0.0.2

func (c ContractBackfiller) Store(ctx context.Context, log types.Log) error

Store stores the logs, receipts, and transactions for a tx hash.

type LogInfo

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

LogInfo is the log info.

type RangeFilter

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

RangeFilter pre-fetches filter logs into a channel in deterministic order.

func NewRangeFilter

func NewRangeFilter(address ethCommon.Address, filterer bind.ContractFilterer, startBlock, endBlock *big.Int, chunkSize int, reverse bool) *RangeFilter

NewRangeFilter creates a new filtering interface for a range of blocks. If reverse is not set, block heights are filtered from start->end.

func (*RangeFilter) Done

func (f *RangeFilter) Done() bool

Done returns a bool indicating whether or not the filtering operation is done.

func (*RangeFilter) Drain

func (f *RangeFilter) Drain(ctx context.Context) (filteredLogs []types.Log, err error)

Drain fetches all logs and concatenated them into a single slice. Deprecated: use the channel.

func (*RangeFilter) FilterLogs

func (f *RangeFilter) FilterLogs(ctx context.Context, chunk *common.Chunk) (*LogInfo, error)

FilterLogs safely calls FilterLogs with the filtering implementing a backoff in the case of rate limiting and respecting context cancellation.

func (*RangeFilter) GetLogChan

func (f *RangeFilter) GetLogChan() chan *LogInfo

GetLogChan retursn a log chan with the logs filtered ahead to bufferSize. Iteration oder is only guaranteed with up to one consumer.

func (*RangeFilter) Start

func (f *RangeFilter) Start(ctx context.Context) error

Start starts the filtering process. If the context is canceled, logs will stop being filtered. Returns an error. this should be run on an independent goroutine.

Jump to

Keyboard shortcuts

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