backfill

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2022 License: MIT Imports: 16 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 ChainBackfiller added in v0.0.2

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

ChainBackfiller is a backfiller that fetches logs for a chain. It aggregates logs from a slice of ContractBackfillers.

func NewChainBackfiller added in v0.0.2

func NewChainBackfiller(chainID uint32, eventDB db.EventDB, client ScribeBackend, chainConfig config.ChainConfig) (*ChainBackfiller, error)

NewChainBackfiller creates a new backfiller for a chain.

func (ChainBackfiller) Backfill added in v0.0.2

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

Backfill iterates over each contract backfiller and calls Backfill concurrently on each one.

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(chainID uint32, address string, eventDB db.EventDB, client ScribeBackend) (*ContractBackfiller, error)

NewContractBackfiller creates a new backfiller for a contract.

func (*ContractBackfiller) Backfill

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.

type LogFilterer added in v0.0.4

type LogFilterer interface {
	// FilterLogs executes a log filter operation, blocking during execution and
	// returning all the results in one batch.
	//
	// TODO(karalabe): Deprecate when the subscription one can return past data too.
	FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error)
}

LogFilterer is the interface for filtering logs.

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 LogFilterer, 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.

func (*RangeFilter) FilterLogs

func (f *RangeFilter) FilterLogs(ctx context.Context, chunk *util.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.

type ScribeBackend added in v0.0.4

type ScribeBackend interface {
	// ChainID gets the chain id from the rpc server
	ChainID(ctx context.Context) (*big.Int, error)
	// TransactionByHash checks the pool of pending transactions in addition to the
	// blockchain. The isPending return value indicates whether the transaction has been
	// mined yet. Note that the transaction may not be part of the canonical chain even if
	// it's not pending.
	TransactionByHash(ctx context.Context, txHash common.Hash) (tx *types.Transaction, isPending bool, err error)
	// TransactionReceipt returns the receipt of a mined transaction. Note that the
	// transaction may not be included in the current canonical chain even if a receipt
	// exists.
	TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
	// BlockNumber gets the latest block number
	BlockNumber(ctx context.Context) (uint64, error)
	// FilterLogs executes a log filter operation, blocking during execution and
	// returning all the results in one batch.
	//
	// TODO(karalabe): Deprecate when the subscription one can return past data too.
	FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error)
}

ScribeBackend is the set of functions that the scribe needs from a client.

type ScribeBackfiller added in v0.0.3

type ScribeBackfiller struct {

	// ChainBackfillers is a mapping of chain IDs -> chain backfillers
	ChainBackfillers map[uint32]*ChainBackfiller
	// contains filtered or unexported fields
}

ScribeBackfiller is a backfiller that aggregates all backfilling from ChainBackfillers.

func NewScribeBackfiller added in v0.0.3

func NewScribeBackfiller(eventDB db.EventDB, clients map[uint32]ScribeBackend, config config.Config) (*ScribeBackfiller, error)

NewScribeBackfiller creates a new backfiller for the scribe.

func (ScribeBackfiller) Backfill added in v0.0.3

func (s ScribeBackfiller) Backfill(ctx context.Context) error

Backfill iterates over each chain backfiller and calls Backfill concurrently on each one.

Jump to

Keyboard shortcuts

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