Documentation
¶
Index ¶
- Variables
- func BinaryRepresentationMinBits(val uint64) int
- func CalcD(numLabels uint64, B uint32) uint
- func DataSize(numLabels uint64, labelSize uint) uint64
- func InitFileName(index int) string
- func IsInitFile(file os.FileInfo) bool
- func NumLabels(dataSize uint64, labelSize uint) uint64
- func PowDifficulty(numLabels uint64) []byte
- func ProvingDifficulty(numLabels uint64, k1 uint64) uint64
- func ProvingDifficulty2(numLabels uint64, B, k1 uint32) uint64
- func PutUintBE(b []byte, v uint64)
- func Size(itemBitSize uint, numItems uint) uint
- func UInt64LE(b []byte) uint64
- func Uint64MulOverflow(a, b uint64) bool
- func UintBE(b []byte) uint64
- func Version() string
- type Challenge
- type ConfigMismatchError
- type DisabledLogger
- type GranSpecificReader
- type GranSpecificWriter
- type Logger
- type PostMetadata
- type Proof
- type ProofMetadata
- type VRFNonce
- type VRFNonceMetadata
Constants ¶
This section is empty.
Variables ¶
var ( ErrInitNotStarted = errors.New("not started") ErrInitCompleted = errors.New("already completed") ErrInitNotCompleted = errors.New("not completed") ErrProofNotExist = errors.New("proof doesn't exist") )
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) )
var ZeroChallenge = make(Challenge, 32)
Functions ¶
func CalcD ¶ added in v0.4.0
CalcD calculates the number of bytes to use for the difficulty check. numLabels is the number of labels contained in the PoST data. B is a network parameter that defines the number of labels used in one AES Block.
func InitFileName ¶
func IsInitFile ¶
func PowDifficulty ¶ added in v0.2.2
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 ProvingDifficulty2 ¶ added in v0.4.0
ProvingDifficulty2 returns the target difficulty of finding a nonce in `numLabels` labels. d is the number of bytes in the AES output that count for one nonce.
func Uint64MulOverflow ¶
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 ConfigMismatchError ¶
func (ConfigMismatchError) Error ¶
func (err ConfigMismatchError) Error() string
type DisabledLogger ¶
type DisabledLogger struct{}
func (DisabledLogger) Debug ¶
func (DisabledLogger) Debug(string, ...any)
func (DisabledLogger) Error ¶
func (DisabledLogger) Error(string, ...any)
func (DisabledLogger) Info ¶
func (DisabledLogger) Info(string, ...any)
func (DisabledLogger) Panic ¶
func (DisabledLogger) Panic(string, ...any)
func (DisabledLogger) Warning ¶
func (DisabledLogger) Warning(string, ...any)
type GranSpecificReader ¶
type GranSpecificReader struct {
ReadNext func() ([]byte, error)
ReadNextUintBE func() (uint64, error)
}
GranSpecificReader provides a wrapper for io.Reader to allow granularity-specific access to the stream according to the defined item size, where bit-granular and byte-granular sizes are supported via a specialized code path.
func NewGranSpecificReader ¶
func NewGranSpecificReader(rd io.Reader, itemBitSize uint) *GranSpecificReader
type GranSpecificWriter ¶
type GranSpecificWriter struct {
Write func([]byte) error
WriteUintBE func(uint64) error
Flush func() error
}
GranSpecificWriter provides a wrapper for io.Writer to allow granularity-specific access to the stream according to the defined item size, where bit-granular and byte-granular sizes are supported via a specialized code path.
func NewGranSpecificWriter ¶
func NewGranSpecificWriter(w io.Writer, itemBitSize uint) *GranSpecificWriter
type PostMetadata ¶ added in v0.2.2
type PostMetadata struct {
NodeId []byte
CommitmentAtxId []byte
BitsPerLabel uint8
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 ProofMetadata ¶
type ProofMetadata struct {
NodeId []byte
CommitmentAtxId []byte
Challenge Challenge
NumUnits uint32
BitsPerLabel uint8
LabelsPerUnit uint64
K1 uint32 // K1 specifies the difficulty for a label to be a candidate for a proof.
K2 uint32 // K2 is the number of labels below the required difficulty required for a proof.
B uint32 // B is the number of labels used per AES invocation when generating a proof. Lower values speed up verification, higher values proof generation.
N uint32 // N is the number of nonces tried at the same time when generating a proof.
}