Documentation
¶
Index ¶
- Variables
- func BinaryRepresentationMinBits(val uint64) int
- 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 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
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, 0)
Functions ¶
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 one computed label is expected to be below the difficulty threshold. The difficulty is calculated as follows:
difficulty = 2^256 / numLabels
TODO(mafa): this difficulty calculation is unfit. There is only a ~ 63% chance to find a nonce in the first `numLabels` labels and only a ~ 90% chance to find a nonce in the first `2*numLabels` labels.
func ProvingDifficulty ¶
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
NumFiles uint32
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.