Documentation
¶
Overview ¶
Package common contains interfaces for the indexer.
Index ¶
- Variables
- func IndexLogs(ctx context.Context, eventChannel <-chan types.Log, contract IContract)
- func IsUpdateProgressEvent(log types.Log) bool
- func NewUpdateProgressLog(blockNumber uint64, blockHash []byte) types.Log
- func UpdateProgressEventSignature() common.Hash
- type Block
- type BlockTracker
- type IBlockTracker
- type IContract
- type ILogStorer
- type ILogStreamer
- type IReorgHandler
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyBlockHash = errors.New("block hash is empty")
Functions ¶
func IndexLogs ¶
IndexLogs will run until the eventChannel is closed, passing each event to the logStorer. If an event fails to be stored, and the error is retryable, it will sleep for 100ms and try again. The only non-retriable errors should be things like malformed events or failed validations.
func IsUpdateProgressEvent ¶ added in v0.5.0
IsUpdateProgressEvent checks if a log is an UpdateProgress event.
func NewUpdateProgressLog ¶ added in v0.5.0
NewUpdateProgressLog creates a types.Log with topic UpdateProgress().
func UpdateProgressEventSignature ¶ added in v0.5.0
UpdateProgressEventSignature returns the Keccak256 hash of the UpdateProgress() event signature.
Types ¶
type BlockTracker ¶
type BlockTracker struct {
// contains filtered or unexported fields
}
BlockTracker keeps a database record of the latest block that has been indexed for a contract address and allows the user to increase the value.
func NewBlockTracker ¶
func NewBlockTracker( ctx context.Context, client blockchain.ChainClient, address common.Address, queries *queries.Queries, deploymentBlock uint64, ) (*BlockTracker, error)
NewBlockTracker returns a new BlockTracker initialized to the latest block from the DB.
func (*BlockTracker) GetLatestBlock ¶
func (bt *BlockTracker) GetLatestBlock() (uint64, []byte)
func (*BlockTracker) UpdateLatestBlock ¶
type IBlockTracker ¶
type IBlockTracker interface {
GetLatestBlock() (uint64, []byte)
UpdateLatestBlock(ctx context.Context, block uint64, hash []byte) error
}
IBlockTracker tracks the latest block number and hash for a contract.
type IContract ¶
type IContract interface {
IBlockTracker
IReorgHandler
ILogStorer
Address() common.Address
Topics() []common.Hash
Logger() *zap.Logger
}
IContract is a contract that can be indexed.
type ILogStorer ¶
ILogStorer takes a log event and stores it, returning either an error that may be retriable, non-retriable, or nil.
type ILogStreamer ¶
An ILogStreamer streams logs from a source through a channel.
type IReorgHandler ¶
IReorgHandler handles reorgs.