listener

package
v0.17.10 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2024 License: MIT Imports: 17 Imported by: 8

Documentation

Overview

Package listener is the listener used to pull in chain events

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrNoLatestBlockForChainID is returned when no block exists for the chain.
	ErrNoLatestBlockForChainID = listenerDB.ErrNoLatestBlockForChainID
)

Functions

This section is empty.

Types

type ContractListener

type ContractListener interface {
	// Listen starts the listener and call HandleLog for each event
	Listen(ctx context.Context, handler HandleLog) error
	// LatestBlock gets the last recorded latest block from the rpc.
	// this is NOT last indexed. It is provided as a helper for checking confirmation count
	LatestBlock() uint64
	// Address gets the address of the contract this listener is listening to
	Address() common.Address
}

ContractListener listens for chain events and calls HandleLog.

func NewChainListener

func NewChainListener(omnirpcClient client.EVM, store listenerDB.ChainListenerDB, address common.Address, initialBlock uint64, handler metrics.Handler, options ...Option) (ContractListener, error)

NewChainListener creates a new chain listener.

type HandleLog

type HandleLog func(ctx context.Context, log types.Log) error

HandleLog is the handler for a log event in the event this errors, the range will be reparsed.

type NewBlockHandler added in v0.11.6

type NewBlockHandler func(ctx context.Context, block uint64) error

NewBlockHandler is a function that is called when a new block is detected.

type Option added in v0.11.6

type Option func(*chainListener)

Option is a functional option for chainListener.

func WithBlockWait added in v0.14.2

func WithBlockWait(wait uint64) Option

WithBlockWait sets the block wait.

func WithFinalityMode added in v0.14.2

func WithFinalityMode(mode string) Option

WithFinalityMode sets the finality mode.

func WithNewBlockHandler added in v0.11.6

func WithNewBlockHandler(handler NewBlockHandler) Option

WithNewBlockHandler sets the new block handler.

func WithPollInterval added in v0.11.7

func WithPollInterval(interval time.Duration) Option

WithPollInterval sets the poll interval.

Directories

Path Synopsis
Package db provides the database layer for the chain listener.
Package db provides the database layer for the chain listener.

Jump to

Keyboard shortcuts

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