logpoller

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Log

type Log struct {
	EvmChainId  *utils.Big
	LogIndex    int64
	BlockHash   common.Hash
	BlockNumber int64
	Topics      pq.ByteaArray
	EventSig    []byte
	Address     common.Address
	TxHash      common.Hash
	Data        []byte
	CreatedAt   time.Time
}

Log represents an EVM log.

type LogPoller

type LogPoller struct {
	utils.StartStopOnce
	// contains filtered or unexported fields
}

func NewLogPoller

func NewLogPoller(orm *ORM, ec client.Client, lggr logger.Logger, pollPeriod time.Duration, finalityDepth, backfillBatchSize int64) *LogPoller

func (*LogPoller) Close

func (lp *LogPoller) Close() error

func (*LogPoller) LatestBlock

func (lp *LogPoller) LatestBlock(qopts ...pg.QOpt) (int64, error)

func (*LogPoller) LatestLogByEventSigWithConfs

func (lp *LogPoller) LatestLogByEventSigWithConfs(eventSig common.Hash, address common.Address, confs int, qopts ...pg.QOpt) (*Log, error)

LatestLogByEventSigWithConfs finds the latest log that has confs number of blocks on top of the log.

func (*LogPoller) Logs

func (lp *LogPoller) Logs(start, end int64, eventSig common.Hash, address common.Address, qopts ...pg.QOpt) ([]Log, error)

Logs returns logs matching topics and address (exactly) in the given block range, which are canonical at time of query.

func (*LogPoller) MergeFilter

func (lp *LogPoller) MergeFilter(topics []common.Hash, address common.Address)

MergeFilter will update the filter with the new topics and addresses. Clients may chose to MergeFilter and then replay in order to ensure desired logs are present.

func (*LogPoller) Replay

func (lp *LogPoller) Replay(ctx context.Context, fromBlock int64) error

Replay signals that the poller should resume from a new block. Blocks until the replay starts.

func (*LogPoller) Start

func (lp *LogPoller) Start(parentCtx context.Context) error

type LogPollerBlock

type LogPollerBlock struct {
	EvmChainId *utils.Big
	BlockHash  common.Hash
	// Note geth uses int64 internally https://github.com/ethereum/go-ethereum/blob/f66f1a16b3c480d3a43ac7e8a09ab3e362e96ae4/eth/filters/api.go#L340
	BlockNumber int64
	CreatedAt   time.Time
}

LogPollerBlock represents an unfinalized block used for reorg detection when polling.

type ORM

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

func NewORM

func NewORM(chainID *big.Int, db *sqlx.DB, lggr logger.Logger, cfg pg.LogConfig) *ORM

NewORM creates an ORM scoped to chainID.

func (*ORM) DeleteLogs

func (o *ORM) DeleteLogs(start, end int64, qopts ...pg.QOpt) error

func (*ORM) DeleteRangeBlocks

func (o *ORM) DeleteRangeBlocks(start, end int64, qopts ...pg.QOpt) error

func (*ORM) InsertBlock

func (o *ORM) InsertBlock(h common.Hash, n int64, qopts ...pg.QOpt) error

InsertBlock is idempotent to support replays.

func (*ORM) InsertLogs

func (o *ORM) InsertLogs(logs []Log, qopts ...pg.QOpt) error

InsertLogs is idempotent to support replays.

func (*ORM) SelectBlockByHash

func (o *ORM) SelectBlockByHash(h common.Hash, qopts ...pg.QOpt) (*LogPollerBlock, error)

func (*ORM) SelectBlockByNumber

func (o *ORM) SelectBlockByNumber(n int64, qopts ...pg.QOpt) (*LogPollerBlock, error)

func (*ORM) SelectLatestBlock

func (o *ORM) SelectLatestBlock(qopts ...pg.QOpt) (*LogPollerBlock, error)

func (*ORM) SelectLatestLogEventSigWithConfs

func (o *ORM) SelectLatestLogEventSigWithConfs(eventSig common.Hash, address common.Address, confs int, qopts ...pg.QOpt) (*Log, error)

func (*ORM) SelectLogsByBlockRangeFilter

func (o *ORM) SelectLogsByBlockRangeFilter(start, end int64, address common.Address, eventSig []byte, qopts ...pg.QOpt) ([]Log, error)

SelectLogsByBlockRangeFilter finds the latest logs by block. Assumes that logs inserted later for a given block are "more" canonical.

Jump to

Keyboard shortcuts

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