Documentation
¶
Index ¶
- Constants
- func Benchmark(p ComputeProvider) (int, error)
- func CPUProviderID() uint
- type ComputeAPIClass
- type ComputeProvider
- type OptionFunc
- func WithBitsPerLabel(bitsPerLabel uint32) OptionFunc
- func WithCommitment(commitment []byte) OptionFunc
- func WithComputeLeaves(enabled bool) OptionFunc
- func WithComputePow(difficulty []byte) OptionFunc
- func WithComputeProviderID(id uint) OptionFunc
- func WithSalt(salt []byte) OptionFunc
- func WithScryptParams(n, r, p uint32) OptionFunc
- func WithStartAndEndPosition(start, end uint64) OptionFunc
- type ScryptPositionsResult
- type StopResult
Constants ¶
const ( ComputeAPIClassUnspecified = ComputeAPIClass((C.ComputeApiClass)(C.COMPUTE_API_CLASS_UNSPECIFIED)) ComputeAPIClassCPU = ComputeAPIClass((C.ComputeApiClass)(C.COMPUTE_API_CLASS_CPU)) ComputeAPIClassCuda = ComputeAPIClass((C.ComputeApiClass)(C.COMPUTE_API_CLASS_CUDA)) ComputeAPIClassVulkan = ComputeAPIClass((C.ComputeApiClass)(C.COMPUTE_API_CLASS_VULKAN)) StopResultPowFound = StopResult(C.SPACEMESH_API_POW_SOLUTION_FOUND) StopResultOk = StopResult(C.SPACEMESH_API_ERROR_NONE) StopResultError = StopResult(C.SPACEMESH_API_ERROR) StopResultErrorTimeout = StopResult(C.SPACEMESH_API_ERROR_TIMEOUT) StopResultErrorAlready = StopResult(C.SPACEMESH_API_ERROR_ALREADY) StopResultErrorCancelled = StopResult(C.SPACEMESH_API_ERROR_CANCELED) StopResultErrorNoCompoteOptions = StopResult(C.SPACEMESH_API_ERROR_NO_COMPOTE_OPTIONS) StopResultErrorInvalidParameter = StopResult(C.SPACEMESH_API_ERROR_INVALID_PARAMETER) StopResultErrorInvalidProvider = StopResult(C.SPACEMESH_API_ERROR_INVALID_PROVIDER_ID) )
const CPUProviderName = "CPU"
Variables ¶
This section is empty.
Functions ¶
func Benchmark ¶
func Benchmark(p ComputeProvider) (int, error)
Benchmark returns the hashes per second the selected compute provider achieves on the current machine.
Types ¶
type ComputeAPIClass ¶
type ComputeAPIClass uint
func (ComputeAPIClass) String ¶
func (c ComputeAPIClass) String() string
type ComputeProvider ¶
type ComputeProvider struct {
ID uint
Model string
ComputeAPI ComputeAPIClass
}
func Providers ¶
func Providers() []ComputeProvider
Providers returns a list of available compute providers.
type OptionFunc ¶ added in v0.2.2
type OptionFunc func(*option) error
func WithBitsPerLabel ¶ added in v0.2.2
func WithBitsPerLabel(bitsPerLabel uint32) OptionFunc
WithBitsPerLabel instructs scrypt to use the specified number of bits per label.
func WithCommitment ¶ added in v0.2.2
func WithCommitment(commitment []byte) OptionFunc
WithCommitment instructs scrypt to use the specified commitment (seed) to calculate the output.
func WithComputeLeaves ¶ added in v0.2.2
func WithComputeLeaves(enabled bool) OptionFunc
WithComputeLeafs instructs scrypt to compute leafs or not. By default computing leafs is enabled.
func WithComputePow ¶ added in v0.2.2
func WithComputePow(difficulty []byte) OptionFunc
WithComputePow instructs scrypt to compute a proof of work or not. If difficulty is nil, no PoW will be computed. Otherwise it specifies the difficulty of the PoW to be computed (higher values are more difficult). By default computing proof of work is disabled.
func WithComputeProviderID ¶ added in v0.2.2
func WithComputeProviderID(id uint) OptionFunc
WithComputeProviderID instructs scrypt to use the specified compute provider.
func WithSalt ¶ added in v0.2.2
func WithSalt(salt []byte) OptionFunc
WithSalt instructs scrypt to use the specified salt to calculate the output.
func WithScryptParams ¶ added in v0.5.1
func WithScryptParams(n, r, p uint32) OptionFunc
func WithStartAndEndPosition ¶ added in v0.2.2
func WithStartAndEndPosition(start, end uint64) OptionFunc
WithStartAndEndPosition instructs scrypt to compute the scrypt output for the specified range of positions.
type ScryptPositionsResult ¶
type ScryptPositionsResult struct {
Output []byte // The output of the scrypt computation.
IdxSolution *uint64 // The index of a solution to the proof of work (if checked for).
HashesPerSec int // The number of hashes computed per second.
Stopped bool // Whether the computation was stopped.
}
ScryptPositionsResult is the result of a ScryptPositions call.
func ScryptPositions ¶
func ScryptPositions(opts ...OptionFunc) (*ScryptPositionsResult, error)
ScryptPositions computes the scrypt output for the given options.
type StopResult ¶
type StopResult int
func Stop ¶
func Stop() StopResult
func (StopResult) String ¶
func (s StopResult) String() string