logpoller

package
v1.8.1-beta0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EvmWord added in v1.5.0

func EvmWord(i uint64) common.Hash

func NewLogPoller

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

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.

func (*Log) GetTopics added in v1.5.0

func (l *Log) GetTopics() []common.Hash

type LogPoller

type LogPoller interface {
	services.ServiceCtx
	Replay(ctx context.Context, fromBlock int64) error
	MergeFilter(eventSigs []common.Hash, addresses []common.Address)
	LatestBlock(qopts ...pg.QOpt) (int64, error)
	GetBlocks(numbers []uint64, qopts ...pg.QOpt) ([]LogPollerBlock, error)

	// General querying
	Logs(start, end int64, eventSig common.Hash, address common.Address, qopts ...pg.QOpt) ([]Log, error)
	LogsWithSigs(start, end int64, eventSigs []common.Hash, address common.Address, qopts ...pg.QOpt) ([]Log, error)
	LatestLogByEventSigWithConfs(eventSig common.Hash, address common.Address, confs int, qopts ...pg.QOpt) (*Log, error)
	LatestLogEventSigsAddrs(fromBlock int64, eventSigs []common.Hash, addresses []common.Address, qopts ...pg.QOpt) ([]Log, error)

	// Content based querying
	IndexedLogs(eventSig common.Hash, address common.Address, topicIndex int, topicValues []common.Hash, confs int, qopts ...pg.QOpt) ([]Log, error)
	IndexedLogsTopicGreaterThan(eventSig common.Hash, address common.Address, topicIndex int, topicValueMin common.Hash, confs int, qopts ...pg.QOpt) ([]Log, error)
	IndexedLogsTopicRange(eventSig common.Hash, address common.Address, topicIndex int, topicValueMin common.Hash, topicValueMax common.Hash, confs int, qopts ...pg.QOpt) ([]Log, error)
	LogsDataWordRange(eventSig common.Hash, address common.Address, wordIndex int, wordValueMin, wordValueMax common.Hash, confs int, qopts ...pg.QOpt) ([]Log, error)
	LogsDataWordGreaterThan(eventSig common.Hash, address common.Address, wordIndex int, wordValueMin common.Hash, confs int, qopts ...pg.QOpt) ([]Log, 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) GetBlocks added in v1.7.0

func (o *ORM) GetBlocks(blockNumbers []uint64, qopts ...pg.QOpt) ([]LogPollerBlock, 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) LatestLogEventSigsAddrs added in v1.5.0

func (o *ORM) LatestLogEventSigsAddrs(fromBlock int64, addresses []common.Address, eventSigs []common.Hash, qopts ...pg.QOpt) ([]Log, error)

LatestLogEventSigsAddrs finds the latest log by (address, event) combination that matches a list of addresses and list of events

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) SelectDataWordGreaterThan added in v1.5.0

func (o *ORM) SelectDataWordGreaterThan(address common.Address, eventSig []byte, wordIndex int, wordValueMin common.Hash, confs int, qopts ...pg.QOpt) ([]Log, error)

func (*ORM) SelectDataWordRange added in v1.5.0

func (o *ORM) SelectDataWordRange(address common.Address, eventSig []byte, wordIndex int, wordValueMin, wordValueMax common.Hash, confs int, qopts ...pg.QOpt) ([]Log, error)

func (*ORM) SelectIndexLogsTopicGreaterThan added in v1.5.0

func (o *ORM) SelectIndexLogsTopicGreaterThan(address common.Address, eventSig []byte, topicIndex int, topicValueMin common.Hash, confs int, qopts ...pg.QOpt) ([]Log, error)

func (*ORM) SelectIndexLogsTopicRange added in v1.5.0

func (o *ORM) SelectIndexLogsTopicRange(address common.Address, eventSig []byte, topicIndex int, topicValueMin, topicValueMax common.Hash, confs int, qopts ...pg.QOpt) ([]Log, error)

func (*ORM) SelectIndexedLogs added in v1.5.0

func (o *ORM) SelectIndexedLogs(address common.Address, eventSig []byte, topicIndex int, topicValues []common.Hash, confs int, qopts ...pg.QOpt) ([]Log, 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 logs in a given block range.

func (*ORM) SelectLogsWithSigsByBlockRangeFilter added in v1.7.0

func (o *ORM) SelectLogsWithSigsByBlockRangeFilter(start, end int64, address common.Address, eventSigs [][]byte, qopts ...pg.QOpt) (logs []Log, err error)

SelectLogsWithSigsByBlockRangeFilter finds the logs in the given block range with the given event signatures emitted from the given address.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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