shared

package
v0.6.6-beta-1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInitNotStarted   = errors.New("not started")
	ErrInitCompleted    = errors.New("already completed")
	ErrInitNotCompleted = errors.New("not completed")
	ErrProofNotExist    = errors.New("proof doesn't exist")
)
View Source
var (
	// OwnerReadWriteExec is a standard owner read / write / exec file permission.
	OwnerReadWriteExec = os.FileMode(0o700)

	// OwnerReadWrite is a standard owner read / write file permission.
	OwnerReadWrite = os.FileMode(0o600)
)
View Source
var ZeroChallenge = make(Challenge, 32)

Functions

func BinaryRepresentationMinBits

func BinaryRepresentationMinBits(val uint64) int

func DataSize

func DataSize(numLabels uint64, labelSize uint) uint64

func InitFileName

func InitFileName(index int) string

func IsInitFile

func IsInitFile(file os.FileInfo) bool

func NumLabels

func NumLabels(dataSize uint64, labelSize uint) uint64

func PowDifficulty added in v0.2.2

func PowDifficulty(numLabels uint64) []byte

PowDifficulty returns the target difficulty of finding a nonce in `numLabels` labels. It is calculated such that a high percentage of smeshers find at least one computed label below the difficulty threshold. The difficulty is calculated as follows:

difficulty = 8 * 2^256 / numLabels

The probability of finding a label below the difficulty threshold within numLabels approaches ~ 99.97% the bigger numLabels gets. Within 1.15 * numLabels the probability approaches 99.99% of finding at least one label below the difficulty threshold.

func ProvingDifficulty

func ProvingDifficulty(numLabels uint64, B, k1 uint32) uint64

ProvingDifficulty returns the target difficulty of finding a nonce in `numLabels` labels.

func PutUintBE

func PutUintBE(b []byte, v uint64)

PutUintBE encodes a uint64 into a big-endian byte slice.

func Size

func Size(itemBitSize uint, numItems uint) uint

func UInt64LE

func UInt64LE(b []byte) uint64

func Uint64MulOverflow

func Uint64MulOverflow(a, b uint64) bool

func UintBE

func UintBE(b []byte) uint64

func Version

func Version() string

Version returns the application version as a properly formed string per the semantic versioning 2.0.0 spec (http://semver.org/).

Types

type Challenge

type Challenge []byte

type ConfigMismatchError

type ConfigMismatchError struct {
	Param    string
	Expected string
	Found    string
	DataDir  string
}

func (ConfigMismatchError) Error

func (err ConfigMismatchError) Error() string

type Logger

type Logger interface {
	Info(format string, args ...any)
	Debug(format string, args ...any)
	Warning(format string, args ...any)
	Error(format string, args ...any)
	Panic(format string, args ...any)
}

type NoopLogger added in v0.6.0

type NoopLogger struct{}

func (NoopLogger) Debug added in v0.6.0

func (NoopLogger) Debug(string, ...any)

func (NoopLogger) Error added in v0.6.0

func (NoopLogger) Error(string, ...any)

func (NoopLogger) Info added in v0.6.0

func (NoopLogger) Info(string, ...any)

func (NoopLogger) Panic added in v0.6.0

func (NoopLogger) Panic(string, ...any)

func (NoopLogger) Warning added in v0.6.0

func (NoopLogger) Warning(string, ...any)

type PostMetadata added in v0.2.2

type PostMetadata struct {
	NodeId          []byte
	CommitmentAtxId []byte

	LabelsPerUnit uint64
	NumUnits      uint32
	MaxFileSize   uint64
	Nonce         *uint64 `json:",omitempty"`
	LastPosition  *uint64 `json:",omitempty"`
}

PostMetadata is the data associated with the PoST init procedure, persisted in the datadir next to the init files.

type Proof

type Proof struct {
	Nonce   uint32
	Indices []byte
	K2Pow   uint64
}

type ProofMetadata

type ProofMetadata struct {
	NodeId          []byte
	CommitmentAtxId []byte

	Challenge     Challenge
	NumUnits      uint32
	LabelsPerUnit uint64
}

type VRFNonce added in v0.2.4

type VRFNonce uint64

type VRFNonceMetadata added in v0.2.4

type VRFNonceMetadata struct {
	NodeId          []byte
	CommitmentAtxId []byte

	NumUnits      uint32
	LabelsPerUnit uint64
}

Jump to

Keyboard shortcuts

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