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 ¶
NewBroadcaster creates a new instance of the broadcaster
Types ¶
type AbigenContract ¶
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 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 }