Skip to main content

Class: PowHelper

Helper methods for POW.

Table of contents

Properties

Methods

Properties

LN3

Static Readonly LN3: number = 1.0986122886681098

LN3 Const see https://oeis.org/A002391. 1.098612288668109691395245236922525704647490557822749451734694333 .

Methods

score

Static score(block): number

Perform the score calculation.

Parameters

NameTypeDescription
blockUint8ArrayThe data to perform the score on.

Returns

number

The score for the data.


calculateTargetZeros

Static calculateTargetZeros(block, targetScore): number

Calculate the number of zeros required to get target score.

Parameters

NameTypeDescription
blockUint8ArrayThe block to process.
targetScorenumberThe target score.

Returns

number

The number of zeros to find.


trailingZeros

Static trailingZeros(powDigest, nonce): number

Calculate the trailing zeros.

Parameters

NameTypeDescription
powDigestUint8ArrayThe pow digest.
nonceBigIntegerThe nonce.

Returns

number

The trailing zeros.


trinaryTrailingZeros

Static trinaryTrailingZeros(trits, endPos?): number

Find the number of trailing zeros.

Parameters

NameTypeDefault valueDescription
tritsInt8ArrayundefinedThe trits to look for zeros.
endPosnumbertrits.lengthThe end position to start looking for zeros.

Returns

number

The number of trailing zeros.


performPow

Static performPow(powDigest, targetZeros, startIndex): string

Perform the hash on the data until we reach target number of zeros.

Parameters

NameTypeDescription
powDigestUint8ArrayThe pow digest.
targetZerosnumberThe target number of zeros.
startIndexstringThe index to start looking from.

Returns

string

The nonce.