common

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package common contains interfaces for the indexer.

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyBlockHash = errors.New("block hash is empty")

Functions

func IndexLogs

func IndexLogs(
	ctx context.Context,
	eventChannel <-chan types.Log,
	contract IContract,
)

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

func IsUpdateProgressEvent(log types.Log) bool

IsUpdateProgressEvent checks if a log is an UpdateProgress event.

func NewUpdateProgressLog added in v0.5.0

func NewUpdateProgressLog(blockNumber uint64, blockHash []byte) types.Log

NewUpdateProgressLog creates a types.Log with topic UpdateProgress().

func UpdateProgressEventSignature added in v0.5.0

func UpdateProgressEventSignature() common.Hash

UpdateProgressEventSignature returns the Keccak256 hash of the UpdateProgress() event signature.

Types

type Block

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

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

func (bt *BlockTracker) UpdateLatestBlock(
	ctx context.Context,
	block uint64,
	hashBytes []byte,
) error

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

type ILogStorer interface {
	StoreLog(ctx context.Context, event types.Log) re.RetryableError
}

ILogStorer takes a log event and stores it, returning either an error that may be retriable, non-retriable, or nil.

type ILogStreamer

type ILogStreamer interface {
	GetEventChannel(id string) <-chan types.Log
	Start() error
	Stop()
}

An ILogStreamer streams logs from a source through a channel.

type IReorgHandler

type IReorgHandler interface {
	HandleLog(ctx context.Context, event types.Log) re.RetryableError
}

IReorgHandler handles reorgs.

Jump to

Keyboard shortcuts

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