Module: bitmessage/pow

Implements proof of work.

Source:
See:

Methods

(static) check(opts) → {boolean}

Check a POW.

Parameters:
Name Type Description
opts Object

Proof of work options

Properties
Name Type Description
target number

Proof of work target or pass getTarget options to opts to compute it

payload Buffer

Message payload (with nonce)

nonce number | Buffer

...or already derived nonce

initialHash Buffer

...and initial hash

Source:
Returns:

Is the proof of work sufficient.

Type
boolean

(static) doAsync(opts) → {Promise.<number>}

Do a POW.

Parameters:
Name Type Description
opts Object

Proof of work options

Properties
Name Type Attributes Description
data Buffer

Object message payload without nonce to get the initial hash from

initialHash Buffer

...or already computed initial hash

target number

POW target

poolSize number <optional>

POW calculation pool size (by default equals to number of cores)

Source:
Returns:

A promise that contains computed nonce for the given target when fulfilled.

Type
Promise.<number>

(static) getTarget(opts) → {number}

Calculate target.

Parameters:
Name Type Description
opts Object

Target options

Properties
Name Type Attributes Description
ttl number

Time to live of the message in seconds

payloadLength number

Length of the message payload (with nonce)

payload Buffer

...or payload itself

nonceTrialsPerByte number <optional>

This number is the average number of nonce trials a node will have to perform to meet the Proof of Work requirement. 1000 is the network minimum so any lower values will be automatically raised to 1000.

payloadLengthExtraBytes number <optional>

This number is added to the data length to make sending small messages more difficult. 1000 is the network minimum so any lower values will be automatically raised to 1000.

Source:
Returns:

Target.

Type
number