oracle

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2025 License: MIT Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrWorkOracleClosed = errors.New("work oracle has been closed")

ErrWorkOracleClosed is returned when calling a method on an already closed WorkOracle instance.

Functions

func CommitmentBytes added in v0.2.2

func CommitmentBytes(nodeId, commitmentAtxId []byte) []byte

CommitmentBytes returns the commitment bytes for the given Node ID and Commitment ATX ID.

Types

type LazyScrypter added in v0.9.0

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

Lazy initialized Scrypter.

func (*LazyScrypter) Close added in v0.9.0

func (l *LazyScrypter) Close() error

func (*LazyScrypter) Positions added in v0.9.0

func (l *LazyScrypter) Positions(start, end uint64) (postrs.ScryptPositionsResult, error)

type OptionFunc added in v0.2.2

type OptionFunc func(*option) error

OptionFunc is a function that sets an option for a WorkOracle instance.

func WithCommitment added in v0.2.2

func WithCommitment(commitment []byte) OptionFunc

WithCommitment sets the commitment to use for the oracle.

func WithLogger added in v0.6.3

func WithLogger(logger *zap.Logger) OptionFunc

WithLogger sets the logger to use.

func WithMaxRetries added in v0.8.3

func WithMaxRetries(maxRetries int) OptionFunc

WithMaxRetries sets the maximum number of retries for a single initialization invocation.

func WithProviderID added in v0.6.0

func WithProviderID(id *uint32) OptionFunc

WithProviderID sets the ID of the OpenCL provider to use.

func WithRetryDelay added in v0.8.3

func WithRetryDelay(retryDelay time.Duration) OptionFunc

WithRetryDelay sets the delay between retries for a single initialization invocation.

func WithScryptParams added in v0.5.1

func WithScryptParams(params config.ScryptParams) OptionFunc

WithScryptParams sets the parameters for the scrypt algorithm. At the moment only configuring N is supported. r and p are fixed at 1 (due to limitations in the OpenCL implementation).

func WithVRFDifficulty added in v0.6.0

func WithVRFDifficulty(difficulty []byte) OptionFunc

WithVRFDifficulty sets the difficulty for the VRF Nonce. It is used as a PoW to make creating identities expensive and thereby prevent Sybil attacks.

type WorkOracle

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

WorkOracle is a service that can compute labels for a given Node ID and CommitmentATX ID.

func New added in v0.6.2

func New(opts ...OptionFunc) (*WorkOracle, error)

New returns a WorkOracle. If not specified, the labels are computed using the default (CPU) provider.

func (*WorkOracle) Close added in v0.6.2

func (w *WorkOracle) Close() error

Close the WorkOracle.

func (*WorkOracle) Position added in v0.6.2

func (w *WorkOracle) Position(p uint64) (WorkOracleResult, error)

Position computes the label for a given position.

func (*WorkOracle) Positions added in v0.6.2

func (w *WorkOracle) Positions(start, end uint64) (WorkOracleResult, error)

Positions computes the labels for a given range of positions.

type WorkOracleResult added in v0.2.2

type WorkOracleResult struct {
	Output []byte  // Output are the computed labels
	Nonce  *uint64 // Nonce is the nonce of the proof of work
}

WorkOracleResult is the result of a call to WorkOracle. It contains the computed labels and a nonce for a proof of work.

Jump to

Keyboard shortcuts

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