Documentation
¶
Overview ¶
Package pow implements proof-of-work and its checking mechanism. More details for PoW for Bitmessage can be found at:
Index ¶
Constants ¶
const ( // DefaultNonceTrialsPerByte is the amount of work that should be performed // (and demanded) per byte of the payload. DefaultNonceTrialsPerByte = 1000 // DefaultExtraBytes is added to the payload length to make sending short // messages a little more difficult. DefaultExtraBytes = 1000 )
If changed, these values will cause particularly unexpected behavior: You won't be able to either send or receive messages because the proof of work you do (or demand) won't match that done or demanded by others. Don't change them!
Variables ¶
var Default = Data{ NonceTrialsPerByte: DefaultNonceTrialsPerByte, ExtraBytes: DefaultExtraBytes, }
Default puts the default values together in one Data struct.
Functions ¶
Types ¶
type Data ¶
Data contains parameters affecting the difficulty required by a particular public key.
type Nonce ¶
type Nonce uint64
Nonce represents a number at the head of an object message which is used for the proof of work.
func DecodeNonce ¶
DecodeNonce decodes a nonce from a reader.
func DoParallel ¶
DoParallel does the POW using parallelCount number of goroutines and returns the nonce value.
func DoSequential ¶
DoSequential does the PoW sequentially and returns the nonce value.
type Target ¶
type Target uint64
func CalculateTarget ¶
CalculateTarget calculates the target POW value. payloadLength includes the full length of the payload (inluding the width of the initial nonce field). ttl is the time difference (in seconds) between ExpiresTime and time.Now(). Information about nonceTrials and extraBytes can be found at: https://bitmessage.org/wiki/Proof_of_work