log

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 11, 2021 License: MIT Imports: 19 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenerJobID

func ListenerJobID(listener Listener) interface{}

ListenerJobID returns the appropriate job ID for a listener

func NewBroadcaster

func NewBroadcaster(orm ORM, ethClient eth.Client, config Config) *broadcaster

NewBroadcaster creates a new instance of the broadcaster

func NewORM

func NewORM(db *gorm.DB) *orm

Types

type AbigenContract

type AbigenContract interface {
	Address() common.Address
	ParseLog(log types.Log) (generated.AbigenLog, error)
}

type Broadcast

type Broadcast interface {
	DecodedLog() interface{}
	RawLog() types.Log
	SetDecodedLog(interface{})
	WasAlreadyConsumed() (bool, error)
	MarkConsumed() error
	String() string
	LatestBlockNumber() uint64
	LatestBlockHash() common.Hash
}

The Broadcast type wraps a types.Log but provides additional functionality for determining whether or not the log has been consumed and for marking the log as consumed

type Broadcaster

type Broadcaster interface {
	utils.DependentAwaiter
	Start() error
	Stop() error
	IsConnected() bool
	Register(listener Listener, opts ListenerOpts) (unsubscribe func())
	SetLatestHeadFromStorage(head *models.Head)
	LatestHead() *models.Head
	TrackedAddressesCount() uint32
}

The Broadcaster manages log subscription requests for the Chainlink node. Instead of creating a new subscription for each request, it multiplexes all subscriptions to all of the relevant contracts over a single connection and forwards the logs to the relevant subscribers.

In case of node crash and/or restart, the logs will be backfilled from the latest head from DB, for subscribers that are added before all dependents of LogBroadcaster are done.

If a subscriber is added after the LogBroadcaster does the initial backfill, then it's possible/likely that the backfill fill only have depth: 1 (from latest head)

Of course, these backfilled logs + any new logs will only be sent after the NumConfirmations for given subscriber.

type Config

type Config interface {
	BlockBackfillDepth() uint64
	EthFinalityDepth() uint
}

type Listener

type Listener interface {
	HandleLog(b Broadcast)
	JobID() models.JobID
	JobIDV2() int32
	IsV2Job() bool
}

The Listener responds to log events through HandleLog, and contains setup/tear-down callbacks in the On* functions.

type ListenerOpts

type ListenerOpts struct {
	Contract         AbigenContract
	Logs             []generated.AbigenLog
	NumConfirmations uint64
}

type ORM

type ORM interface {
	WasBroadcastConsumed(blockHash common.Hash, logIndex uint, jobID interface{}) (bool, error)
	MarkBroadcastConsumed(blockHash common.Hash, blockNumber uint64, logIndex uint, jobID interface{}) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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