Documentation ¶
Index ¶
Constants ¶
View Source
const NonceBytes = 8
NonceBytes specifies the number of bytes required for the nonce.
Variables ¶
View Source
var ( ErrCancelled = errors.New("canceled") ErrDone = errors.New("done") )
errors returned by the PoW
Functions ¶
This section is empty.
Types ¶
type Hash ¶
type Hash interface { // Size returns the length, in bytes, of a digest resulting from the given hash function. Size() int // New returns a new hash.Hash calculating the given hash function. New() hash.Hash }
Hash identifies a cryptographic hash function that is implemented in another package.
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
The Worker provides PoW functionality using an arbitrary hash function.
func New ¶
New creates a new PoW based on the provided hash. The optional numWorkers specifies how many go routines are used to mine.
func (*Worker) LeadingZeros ¶
LeadingZeros returns the number of leading zeros in the digest of the given data.
func (*Worker) LeadingZerosWithNonce ¶
LeadingZerosWithNonce returns the number of leading zeros in the digest after the provided 8-byte nonce is appended to msg.
Click to show internal directories.
Click to hide internal directories.