shared

package
v0.12.6 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: MIT Imports: 10 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInitNotStarted   = errors.New("not started")
	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 ParseFileIndex added in v0.8.7

func ParseFileIndex(fileName string) (int, error)

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, 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

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 NonceValue added in v0.8.7

type NonceValue []byte

func (NonceValue) MarshalJSON added in v0.8.7

func (n NonceValue) MarshalJSON() ([]byte, error)

func (*NonceValue) UnmarshalJSON added in v0.8.7

func (n *NonceValue) UnmarshalJSON(data []byte) (err error)

type PostMetadata added in v0.2.2

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

	LabelsPerUnit uint64
	NumUnits      uint32
	MaxFileSize   uint64
	Nonce         *uint64    `json:",omitempty"`
	NonceValue    NonceValue `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
	Pow     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