initialization

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: 24 Imported by: 2

Documentation

Index

Constants

View Source
const MetadataFileName = "postdata_metadata.json"

Variables

View Source
var (
	ErrAlreadyInitializing          = errors.New("already initializing")
	ErrCannotResetWhileInitializing = errors.New("cannot reset while initializing")
	ErrStateMetadataFileMissing     = errors.New("metadata file is missing")
)
View Source
var ErrNonceNotFound = errors.New("nonce not found")

Functions

func Benchmark added in v0.6.0

func Benchmark(p Provider) (int, error)

Benchmark returns the hashes per second the selected compute provider achieves on the current machine.

func CPUProviderID

func CPUProviderID() uint32

CPUProviderID returns the ID of the CPU provider or nil if the CPU provider is not available.

func GetFiles added in v0.3.0

func GetFiles(dir string, predicate func(os.FileInfo) bool) ([]os.FileInfo, error)

func LoadMetadata

func LoadMetadata(dir string) (*shared.PostMetadata, error)

func SaveMetadata

func SaveMetadata(dir string, v *shared.PostMetadata) error

func SearchForNonce added in v0.8.9

func SearchForNonce(
	ctx context.Context,
	cfg Config,
	initOpts InitOpts,
	opts ...searchForNonceOpt,
) (nonce uint64, nonceValue []byte, err error)

SearchForNonce is searches for a nonce in the already initialized data. Will return ErrNonceNotFound if no nonce was found. Otherwise, it will return the nonce the 16B of label it points to.

func SearchWithLogger added in v0.8.9

func SearchWithLogger(logger *zap.Logger) searchForNonceOpt

Types

type Config

type Config = config.Config

type ConfigMismatchError

type ConfigMismatchError = shared.ConfigMismatchError

type DiskState

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

func NewDiskState

func NewDiskState(datadir string, bitsPerLabel uint) *DiskState

func (*DiskState) NumBytesWritten

func (d *DiskState) NumBytesWritten() (uint64, error)

func (*DiskState) NumFilesWritten added in v0.3.0

func (d *DiskState) NumFilesWritten() (int, error)

func (*DiskState) NumLabelsWritten

func (d *DiskState) NumLabelsWritten() (uint64, error)

type ErrReferenceLabelMismatch added in v0.8.8

type ErrReferenceLabelMismatch struct {
	Index      uint64
	Commitment []byte

	Expected []byte
	Actual   []byte
}

func (ErrReferenceLabelMismatch) Error added in v0.8.8

type InitOpts

type InitOpts = config.InitOpts

type Initializer

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

Initializer is responsible for initializing a new PoST commitment.

func NewInitializer

func NewInitializer(opts ...OptionFunc) (*Initializer, error)

func (*Initializer) Initialize

func (init *Initializer) Initialize(ctx context.Context) error

Initialize is the process in which the prover commits to store some data, by having its storage filled with pseudo-random data with respect to a specific id. This data is the result of a computationally-expensive operation.

func (*Initializer) Nonce added in v0.2.2

func (init *Initializer) Nonce() *uint64

func (*Initializer) NonceValue added in v0.8.10

func (init *Initializer) NonceValue() []byte

func (*Initializer) NumLabelsWritten added in v0.2.2

func (init *Initializer) NumLabelsWritten() uint64

func (*Initializer) Reset

func (init *Initializer) Reset() error

func (*Initializer) Status added in v0.2.0

func (init *Initializer) Status() Status

type Logger

type Logger = zap.Logger

type OptionFunc added in v0.2.2

type OptionFunc func(*option) error

func WithCommitmentAtxId added in v0.2.2

func WithCommitmentAtxId(id []byte) OptionFunc

WithCommitmentAtxId sets the ID of the CommitmentATX.

func WithConfig added in v0.2.0

func WithConfig(cfg Config) OptionFunc

WithConfig sets the config for the initializer.

func WithInitOpts added in v0.2.0

func WithInitOpts(initOpts config.InitOpts) OptionFunc

WithInitOpts sets the init options for the initializer.

func WithLogger added in v0.2.0

func WithLogger(logger *zap.Logger) OptionFunc

WithLogger sets the logger for the initializer.

func WithNodeId added in v0.2.2

func WithNodeId(nodeId []byte) OptionFunc

WithNodeId sets the ID of the Node.

type Provider added in v0.6.1

type Provider = postrs.Provider

func OpenCLProviders added in v0.6.0

func OpenCLProviders() ([]Provider, error)

Providers returns a list of available compute providers.

type Status added in v0.2.0

type Status int
const (
	StatusNotStarted Status = iota
	StatusStarted
	StatusInitializing
	StatusCompleted
	StatusError
)

Jump to

Keyboard shortcuts

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