Documentation ¶
Overview ¶
Package backfill is used to get logs from previous blocks
Index ¶
- type ContractBackfiller
- func (c ContractBackfiller) Backfill(ctx context.Context, givenStart uint64, endHeight uint64) error
- func (c ContractBackfiller) GetLogs(ctx context.Context, startHeight, endHeight uint64) (logsChan <-chan types.Log, errsChan <-chan error, completeChan <-chan bool)
- func (c ContractBackfiller) StartHeightForBackfill(ctx context.Context, givenStart uint64) (startHeight uint64, err error)
- func (c ContractBackfiller) Store(ctx context.Context, log types.Log) error
- 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
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.
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 ¶
Drain fetches all logs and concatenated them into a single slice. Deprecated: use the channel.
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.