Documentation ¶
Overview ¶
Package backfill is used to get logs from previous blocks
Index ¶
- type ChainBackfiller
- type ContractBackfiller
- type LogFilterer
- type LogInfo
- type RangeFilter
- func (f *RangeFilter) Done() bool
- func (f *RangeFilter) Drain(ctx context.Context) (filteredLogs []types.Log, err error)
- func (f *RangeFilter) FilterLogs(ctx context.Context, chunk *common.Chunk) (*LogInfo, error)
- func (f *RangeFilter) GetLogChan() chan *LogInfo
- func (f *RangeFilter) Start(ctx context.Context) error
- type ScribeBackend
- type ScribeBackfiller
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.
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) FilterLogs ¶
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.
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.