{"modulePath":"github.com/GoPlugin/pluginV2","version":"v0.5.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package log\n\n## Functions\n\n```go\nfunc NewBroadcaster(orm ORM, ethClient evmclient.Client, config Config, lggr logger.Logger, highestSavedHead *evmtypes.Head, mailMon *utils.MailboxMonitor) *broadcaster\n```\nNewBroadcaster creates a new instance of the broadcaster\n\n```go\nfunc NewORM(db *sqlx.DB, lggr logger.Logger, cfg pg.QConfig, evmChainID big.Int) *orm\n```\n\n## Types\n\n```go\ntype AbigenContract interface {\n\tAddress() common.Address\n\tParseLog(log types.Log) (generated.AbigenLog, error)\n}\n```\n\n```go\ntype Broadcast interface {\n\tDecodedLog() interface{}\n\tRawLog() types.Log\n\tString() string\n\tLatestBlockNumber() uint64\n\tLatestBlockHash() common.Hash\n\tReceiptsRoot() common.Hash\n\tTransactionsRoot() common.Hash\n\tStateRoot() common.Hash\n\tJobID() int32\n\tEVMChainID() big.Int\n}\n```\nThe 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\n\n```go\nfunc NewLogBroadcast(rawLog types.Log, evmChainID big.Int, decodedLog interface{}) Broadcast\n```\n\n```go\ntype Broadcaster interface {\n\tutils.DependentAwaiter\n\tservices.ServiceCtx\n\thttypes.HeadTrackable\n\n\t// ReplayFromBlock enqueues a replay from the provided block number. If forceBroadcast is\n\t// set to true, the broadcaster will broadcast logs that were already marked consumed\n\t// previously by any subscribers.\n\tReplayFromBlock(number int64, forceBroadcast bool)\n\n\tIsConnected() bool\n\tRegister(listener Listener, opts ListenerOpts) (unsubscribe func())\n\n\tWasAlreadyConsumed(lb Broadcast, qopts ...pg.QOpt) (bool, error)\n\tMarkConsumed(lb Broadcast, qopts ...pg.QOpt) error\n\n\t// MarkManyConsumed marks all the provided log broadcasts as consumed.\n\tMarkManyConsumed(lbs []Broadcast, qopts ...pg.QOpt) error\n}\n```\nThe 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.\n\nIn case of node crash and/or restart, the logs will be backfilled for subscribers that are added before all dependents of LogBroadcaster are done.\n\nThe backfill starts from the earliest block of either:\n\n  - Latest DB head minus BlockBackfillDepth and the maximum number of confirmations.\n  - Earliest pending or unconsumed log broadcast from DB.\n\nIf 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)\n\nOf course, these backfilled logs + any new logs will only be sent after the NumConfirmations for given subscriber.\n\n```go\ntype BroadcasterInTest interface {\n\tBroadcaster\n\tBackfillBlockNumber() null.Int64\n\tTrackedAddressesCount() uint32\n\t// Pause pauses the eventLoop until Resume is called.\n\tPause()\n\t// Resume resumes the eventLoop after calling Pause.\n\tResume()\n\tLogsFromBlock(bh common.Hash) int\n}\n```\n\n```go\ntype Config interface {\n\tBlockBackfillDepth() uint64\n\tBlockBackfillSkip() bool\n\tEvmFinalityDepth() uint32\n\tEvmLogBackfillBatchSize() uint32\n}\n```\n\n```go\ntype Listener interface {\n\tHandleLog(b Broadcast)\n\tJobID() int32\n}\n```\nThe Listener responds to log events through HandleLog.\n\n```go\ntype ListenerOpts struct {\n\tContract common.Address\n\n\t// Event types to receive, with value filter for each field in the event\n\t// No filter or an empty filter for a given field position mean: all values allowed\n\t// the key should be a result of AbigenLog.Topic() call\n\t// topic =\u003e topicValueFilters\n\tLogsWithTopics map[common.Hash][][]Topic\n\n\tParseLog ParseLogFunc\n\n\t// Minimum number of block confirmations before the log is received\n\tMinIncomingConfirmations uint32\n\n\t// ReplayStartedCallback is called by the log broadcaster once a replay request is received.\n\tReplayStartedCallback func()\n}\n```\n\n```go\ntype LogBroadcast struct {\n\tBlockHash common.Hash\n\tConsumed  bool\n\tLogIndex  uint\n\tJobID     int32\n}\n```\nLogBroadcast - data from log\\_broadcasts table columns\n\n```go\nfunc (b LogBroadcast) AsKey() LogBroadcastAsKey\n```\n\n```go\ntype LogBroadcastAsKey struct {\n\tBlockHash common.Hash\n\tLogIndex  uint\n\tJobId     int32\n}\n```\nLogBroadcastAsKey - used as key in a map to filter out already consumed logs\n\n```go\nfunc NewLogBroadcastAsKey(log types.Log, listener Listener) LogBroadcastAsKey\n```\n\n```go\ntype NullBroadcaster struct{ ErrMsg string }\n```\n\n```go\nfunc (n *NullBroadcaster) AddDependents(int)\n```\n\n```go\nfunc (n *NullBroadcaster) AwaitDependents() \u003c-chan struct{}\n```\n\n```go\nfunc (n *NullBroadcaster) BackfillBlockNumber() null.Int64\n```\n\n```go\nfunc (n *NullBroadcaster) Close() error\n```\n\n```go\nfunc (n *NullBroadcaster) DependentReady()\n```\nDependentReady does noop for NullBroadcaster.\n\n```go\nfunc (n *NullBroadcaster) HealthReport() map[string]error\n```\n\n```go\nfunc (n *NullBroadcaster) Healthy() error\n```\n\n```go\nfunc (n *NullBroadcaster) IsConnected() bool\n```\n\n```go\nfunc (n *NullBroadcaster) LogsFromBlock(common.Hash) int\n```\n\n```go\nfunc (n *NullBroadcaster) MarkConsumed(lb Broadcast, qopts ...pg.QOpt) error\n```\n\n```go\nfunc (n *NullBroadcaster) MarkManyConsumed(lbs []Broadcast, qopts ...pg.QOpt) error\n```\n\n```go\nfunc (n *NullBroadcaster) Name() string\n```\n\n```go\nfunc (n *NullBroadcaster) OnNewLongestChain(context.Context, *evmtypes.Head)\n```\n\n```go\nfunc (n *NullBroadcaster) Pause()\n```\n\n```go\nfunc (n *NullBroadcaster) Ready() error\n```\n\n```go\nfunc (n *NullBroadcaster) Register(listener Listener, opts ListenerOpts) (unsubscribe func())\n```\n\n```go\nfunc (n *NullBroadcaster) ReplayFromBlock(number int64, forceBroadcast bool)\n```\nReplayFromBlock implements the Broadcaster interface.\n\n```go\nfunc (n *NullBroadcaster) Resume()\n```\n\n```go\nfunc (n *NullBroadcaster) Start(context.Context) error\n```\nStart does noop for NullBroadcaster.\n\n```go\nfunc (n *NullBroadcaster) TrackedAddressesCount() uint32\n```\n\n```go\nfunc (n *NullBroadcaster) WasAlreadyConsumed(lb Broadcast, qopts ...pg.QOpt) (bool, error)\n```\n\n```go\ntype ORM interface {\n\t// FindBroadcasts returns broadcasts for a range of block numbers, both consumed and unconsumed.\n\tFindBroadcasts(fromBlockNum int64, toBlockNum int64) ([]LogBroadcast, error)\n\t// CreateBroadcast inserts an unconsumed log broadcast for jobID.\n\tCreateBroadcast(blockHash common.Hash, blockNumber uint64, logIndex uint, jobID int32, qopts ...pg.QOpt) error\n\t// WasBroadcastConsumed returns true if jobID consumed the log broadcast.\n\tWasBroadcastConsumed(blockHash common.Hash, logIndex uint, jobID int32, qopts ...pg.QOpt) (bool, error)\n\t// MarkBroadcastConsumed marks the log broadcast as consumed by jobID.\n\tMarkBroadcastConsumed(blockHash common.Hash, blockNumber uint64, logIndex uint, jobID int32, qopts ...pg.QOpt) error\n\t// MarkBroadcastsConsumed marks the log broadcasts as consumed by jobID.\n\tMarkBroadcastsConsumed(blockHashes []common.Hash, blockNumbers []uint64, logIndexes []uint, jobIDs []int32, qopts ...pg.QOpt) error\n\t// MarkBroadcastsUnconsumed marks all log broadcasts from all jobs on or after fromBlock as\n\t// unconsumed.\n\tMarkBroadcastsUnconsumed(fromBlock int64, qopts ...pg.QOpt) error\n\n\t// SetPendingMinBlock sets the minimum block number for which there are pending broadcasts in the pool, or nil if empty.\n\tSetPendingMinBlock(blockNum *int64, qopts ...pg.QOpt) error\n\t// GetPendingMinBlock returns the minimum block number for which there were pending broadcasts in the pool, or nil if it was empty.\n\tGetPendingMinBlock(qopts ...pg.QOpt) (blockNumber *int64, err error)\n\n\t// Reinitialize cleans up the database by removing any unconsumed broadcasts, then updating (if necessary) and\n\t// returning the pending minimum block number.\n\tReinitialize(qopts ...pg.QOpt) (blockNumber *int64, err error)\n}\n```\nORM is the interface for log broadcasts.\n\n  - Unconsumed broadcasts are created just before notifying subscribers, who are responsible for marking them consumed.\n  - Pending broadcast block numbers are synced to the min from the pool (or deleted when empty)\n  - On reboot, backfill considers the min block number from unconsumed and pending broadcasts. Additionally, unconsumed entries are removed and the pending broadcasts number updated.\n\n```go\ntype ParseLogFunc func(log types.Log) (generated.AbigenLog, error)\n```\n\n```go\ntype Topic common.Hash\n```\n\n```go\ntype Uint64 uint64\n```\n\n```go\nfunc (a Uint64) Compare(b heaps.Item) int\n```\n\n","path":"github.com/GoPlugin/pluginV2/core/chains/evm/log","name":"log","synopsis":"","isRedistributable":true}
