blockhashstore

package
v1.13.3 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2023 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidatedSpec

func ValidatedSpec(tomlString string) (job.Job, error)

ValidatedSpec validates and converts the given toml string to a job.Job.

Types

type BHS

type BHS interface {
	// Store the hash associated with blockNum.
	Store(ctx context.Context, blockNum uint64) error

	// IsStored checks whether the hash associated with blockNum is already stored.
	IsStored(ctx context.Context, blockNum uint64) (bool, error)
}

BHS defines an interface for interacting with a BlockhashStore contract.

type BulletproofBHS

type BulletproofBHS struct {
	// contains filtered or unexported fields
}

BulletproofBHS is an implementation of BHS that writes "store" transactions to a bulletproof transaction manager, and reads BlockhashStore state from the contract.

func NewBulletproofBHS

func NewBulletproofBHS(
	config bpBHSConfig,
	fromAddresses []ethkey.EIP55Address,
	txm txmgr.TxManager,
	bhs blockhash_store.BlockhashStoreInterface,
	chainID *big.Int,
	gethks keystore.Eth,
) (*BulletproofBHS, error)

NewBulletproofBHS creates a new instance with the given transaction manager and blockhash store.

func (*BulletproofBHS) IsStored

func (c *BulletproofBHS) IsStored(ctx context.Context, blockNum uint64) (bool, error)

IsStored satisfies the BHS interface.

func (*BulletproofBHS) Store

func (c *BulletproofBHS) Store(ctx context.Context, blockNum uint64) error

Store satisfies the BHS interface.

type Coordinator

type Coordinator interface {
	// Requests fetches VRF requests that occurred within the specified blocks.
	Requests(ctx context.Context, fromBlock uint64, toBlock uint64) ([]Event, error)

	// Fulfillments fetches VRF fulfillments that occurred since the specified block.
	Fulfillments(ctx context.Context, fromBlock uint64) ([]Event, error)
}

Coordinator defines an interface for fetching request and fulfillment metadata from a VRF coordinator.

func NewMultiCoordinator

func NewMultiCoordinator(coordinators ...Coordinator) Coordinator

NewMultiCoordinator creates a new Coordinator that combines the results of the given coordinators.

type Delegate

type Delegate struct {
	// contains filtered or unexported fields
}

Delegate creates BlockhashStore feeder jobs.

func NewDelegate

func NewDelegate(
	logger logger.Logger,
	chains evm.ChainSet,
	ks keystore.Eth,
) *Delegate

NewDelegate creates a new Delegate.

func (*Delegate) AfterJobCreated

func (d *Delegate) AfterJobCreated(spec job.Job)

AfterJobCreated satisfies the job.Delegate interface.

func (*Delegate) BeforeJobCreated added in v1.11.0

func (d *Delegate) BeforeJobCreated(spec job.Job)

func (*Delegate) BeforeJobDeleted

func (d *Delegate) BeforeJobDeleted(spec job.Job)

BeforeJobDeleted satisfies the job.Delegate interface.

func (*Delegate) JobType

func (d *Delegate) JobType() job.Type

JobType satisfies the job.Delegate interface.

func (*Delegate) ServicesForSpec

func (d *Delegate) ServicesForSpec(jb job.Job) ([]job.ServiceCtx, error)

ServicesForSpec satisfies the job.Delegate interface.

type Event

type Event struct {
	// ID of the relevant VRF request. For a VRF V1 request, this will an encoded 32 byte array.
	// For VRF V2, it will be an integer in string form.
	ID string

	// Block that the request or fulfillment was included in.
	Block uint64
}

Event contains metadata about a VRF randomness request or fulfillment.

type Feeder

type Feeder struct {
	// contains filtered or unexported fields
}

Feeder checks recent VRF coordinator events and stores any blockhashes for blocks within waitBlocks and lookbackBlocks that have unfulfilled requests.

func NewFeeder

func NewFeeder(
	logger logger.Logger,
	coordinator Coordinator,
	bhs BHS,
	waitBlocks int,
	lookbackBlocks int,
	latestBlock func(ctx context.Context) (uint64, error),
) *Feeder

NewFeeder creates a new Feeder instance.

func (*Feeder) Run

func (f *Feeder) Run(ctx context.Context) error

Run the feeder.

type MultiCoordinator

type MultiCoordinator []Coordinator

MultiCoordinator combines the data from multiple coordinators.

func (MultiCoordinator) Fulfillments

func (m MultiCoordinator) Fulfillments(ctx context.Context, fromBlock uint64) ([]Event, error)

Fulfillments satisfies the Coordinator interface.

func (MultiCoordinator) Requests

func (m MultiCoordinator) Requests(
	ctx context.Context,
	fromBlock uint64,
	toBlock uint64,
) ([]Event, error)

Requests satisfies the Coordinator interface.

type V1Coordinator

type V1Coordinator struct {
	// contains filtered or unexported fields
}

V1Coordinator fetches request and fulfillment logs from a VRF V1 coordinator contract.

func NewV1Coordinator

func NewV1Coordinator(c v1.VRFCoordinatorInterface) *V1Coordinator

NewV1Coordinator creates a new V1Coordinator from the given contract.

func (*V1Coordinator) Fulfillments

func (v *V1Coordinator) Fulfillments(ctx context.Context, fromBlock uint64) ([]Event, error)

Fulfillments satisfies the Coordinator interface.

func (*V1Coordinator) Requests

func (v *V1Coordinator) Requests(
	ctx context.Context,
	fromBlock uint64,
	toBlock uint64,
) ([]Event, error)

Requests satisfies the Coordinator interface.

type V2Coordinator

type V2Coordinator struct {
	// contains filtered or unexported fields
}

V2Coordinator fetches request and fulfillment logs from a VRF V2 coordinator contract.

func NewV2Coordinator

func NewV2Coordinator(c v2.VRFCoordinatorV2Interface) *V2Coordinator

NewV2Coordinator creates a new V2Coordinator from the given contract.

func (*V2Coordinator) Fulfillments

func (v *V2Coordinator) Fulfillments(ctx context.Context, fromBlock uint64) ([]Event, error)

Fulfillments satisfies the Coordinator interface.

func (*V2Coordinator) Requests

func (v *V2Coordinator) Requests(
	ctx context.Context,
	fromBlock uint64,
	toBlock uint64,
) ([]Event, error)

Requests satisfies the Coordinator interface.

Jump to

Keyboard shortcuts

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