v1

package
v2.9.1-vrf-20240219 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 29 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 {
	services.StateMachine

	Cfg            vrfcommon.Config
	FeeCfg         vrfcommon.FeeConfig
	L              logger.SugaredLogger
	Coordinator    *solidity_vrf_coordinator_interface.VRFCoordinator
	PipelineRunner pipeline.Runner
	Job            job.Job
	Q              pg.Q
	GethKs         vrfcommon.GethKeyStore
	MailMon        *mailbox.Monitor
	ReqLogs        *mailbox.Mailbox[log.Broadcast]
	ChStop         services.StopChan
	WaitOnStop     chan struct{}
	NewHead        chan struct{}
	LatestHead     uint64
	LatestHeadMu   sync.RWMutex
	Chain          legacyevm.Chain

	// 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) GetStartingResponseCountsV1 added in v2.8.0

func (lsn *Listener) GetStartingResponseCountsV1(ctx context.Context) (respCount map[[32]byte]uint64, err error)

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(ctx 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