v1

package
v2.5.1-mercury-20230908 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2023 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Listener

type Listener struct {
	utils.StartStopOnce

	Cfg             vrfcommon.Config
	FeeCfg          vrfcommon.FeeConfig
	L               logger.SugaredLogger
	LogBroadcaster  log.Broadcaster
	Coordinator     *solidity_vrf_coordinator_interface.VRFCoordinator
	PipelineRunner  pipeline.Runner
	Job             job.Job
	Q               pg.Q
	HeadBroadcaster httypes.HeadBroadcasterRegistry
	Txm             txmgr.TxManager
	GethKs          vrfcommon.GethKeyStore
	MailMon         *utils.MailboxMonitor
	ReqLogs         *utils.Mailbox[log.Broadcast]
	ChStop          utils.StopChan
	WaitOnStop      chan struct{}
	NewHead         chan struct{}
	LatestHead      uint64
	LatestHeadMu    sync.RWMutex

	// We can keep these pending logs in memory because we
	// only mark them confirmed once we send a corresponding fulfillment transaction.
	// So on node restart in the middle of processing, the lb will resend them.
	ReqsMu   sync.Mutex // Both goroutines write to Reqs
	Reqs     []request
	ReqAdded func() // A simple debug helper

	// Data structures for reorg attack protection
	// We want a map so we can do an O(1) count update every fulfillment log we get.
	RespCountMu   sync.Mutex
	ResponseCount map[[32]byte]uint64
	// This auxiliary heap is to used when we need to purge the
	// ResponseCount map - we repeatedly want remove the minimum log.
	// You could use a sorted list if the completed logs arrive in order, but they may not.
	BlockNumberToReqID *pairing.PairHeap

	// Deduper prevents processing duplicate requests from the log broadcaster.
	Deduper *vrfcommon.LogDeduper
}

func (*Listener) Close

func (lsn *Listener) Close() error

Close complies with job.Service

func (*Listener) HandleLog

func (lsn *Listener) HandleLog(lb log.Broadcast)

func (*Listener) JobID

func (lsn *Listener) JobID() int32

Job complies with log.Listener

func (*Listener) OnNewLongestChain

func (lsn *Listener) OnNewLongestChain(_ context.Context, head *evmtypes.Head)

Note that we have 2 seconds to do this processing

func (*Listener) ProcessRequest

func (lsn *Listener) ProcessRequest(ctx context.Context, req request) bool

ProcessRequest attempts to process the VRF request. Returns true if successful, false otherwise.

func (*Listener) ReplayStartedCallback

func (lsn *Listener) ReplayStartedCallback()

ReplayStartedCallback is called by the log broadcaster when a replay is about to start.

func (*Listener) ReqsConfirmedAt

func (lsn *Listener) ReqsConfirmedAt() (us []uint64)

func (*Listener) RespCount

func (lsn *Listener) RespCount(reqIDBytes [32]byte) uint64

func (*Listener) RunHeadListener

func (lsn *Listener) RunHeadListener(unsubscribe func())

Listen for new heads

func (*Listener) RunLogListener

func (lsn *Listener) RunLogListener(unsubscribes []func(), minConfs uint32)

func (*Listener) SetReqAdded

func (lsn *Listener) SetReqAdded(fn func())

func (*Listener) SetRespCount

func (lsn *Listener) SetRespCount(reqIDBytes [32]byte, c uint64)

func (*Listener) Start

func (lsn *Listener) Start(context.Context) error

Start complies with job.Service

func (*Listener) Stop

func (lsn *Listener) Stop(t *testing.T)

Jump to

Keyboard shortcuts

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