Members

(static) eqsolve

Performs an equihash solution using defaults

(static) eqverify

Perform an equihash proof verification

Methods

(static) compareKeyBuffers(b1, b2) → {number}

Compare two buffers for sorting

Parameters:
NameTypeDescription
b1buffer

Buffer to compare

b2buffer

Buffer to compare

Returns:
Type: 
number

(static) generatePrivateKey() → {buffer}

Generates a private key

Returns:
Type: 
buffer

(static) getBucketIndex(referenceKey, foreignKey) → {number}

Calculate the index of the bucket that key would belong to

Parameters:
NameTypeDescription
referenceKeystring

Key to compare

foreignKeystring

Key to compare

Returns:
Type: 
number

(static) getContactURL(contact) → {string}

Returns a stringified URL from the supplied contact object

Parameters:
NameTypeDescription
contactBucket~contact
Returns:
Type: 
string

(static) getDistance(key1, key2) → {buffer}

Calculate the distance between two keys

Parameters:
NameTypeDescription
key1string

Identity key to compare

key2string

Identity key to compare

Returns:
Type: 
buffer

(static) getPowerOfTwoBufferForIndex(referenceKey, bucketIndex) → {buffer}

Returns a buffer with a power-of-two value given a bucket index

Parameters:
NameTypeDescription
referenceKeystring | buffer

Key to find next power of two

bucketIndexnumber

Bucket index for key

Returns:
Type: 
buffer

(static) getRandomBufferInBucketRange(referenceKey, index)

Generate a random number within the bucket's range

Parameters:
NameTypeDescription
referenceKeybuffer

Key for bucket distance reference

indexnumber

Bucket index for random buffer selection

(static) getRandomKeyBuffer() → {buffer}

Returns a random valid key/identity as a buffer

Returns:
Type: 
buffer

(static) getRandomKeyString() → {string}

Returns a random valid key/identity as a string

Returns:
Type: 
string

(static) hash160(input)

Returns the RMD-160 hash of the input

Parameters:
NameTypeDescription
inputbuffer

Data to hash

(static) hash256(input)

Returns the SHA-256 hash of the input

Parameters:
NameTypeDescription
inputbuffer

Data to hash

(static) isCompatibleVersion(version) → {boolean}

Returns whether or not the supplied semver tag is compatible

Parameters:
NameTypeDescription
versionstring

The semver tag from the contact

Returns:
Type: 
boolean

(static) isHexaString(str) → {boolean}

Tests if a string is valid hex

Parameters:
NameTypeDescription
strstring
Returns:
Type: 
boolean

(static) isValidContact(contact, loopback) → {boolean}

Determines if the supplied contact is valid

Parameters:
NameTypeDescription
contactBucket~contact

The contact information for a given peer

loopbackboolean

Allows contacts that are localhost

Returns:
Type: 
boolean

(static) keyBufferIsValid(key) → {boolean}

Determines if the given buffer key is valid

Parameters:
NameTypeDescription
keybuffer

Node ID or item key

Returns:
Type: 
boolean

(static) keyStringIsValid(key) → {boolean}

Determines if the given string key is valid

Parameters:
NameTypeDescription
keystring

Node ID or item key

Returns:
Type: 
boolean

(static) parseContactURL() → {object}

Returns a parsed contact object from a URL

Returns:
Type: 
object

(static) preventConvoy(func, maxtimeopt) → {function}

Wraps the supplied function in a pseudo-random length timeout to help prevent convoy effects. These occur when a number of processes need to use a resource in turn. There is a tendency for such bursts of activity to drift towards synchronization, which can be disasterous. In Kademlia all nodes are requird to republish their contents every hour (T_REPLICATE). A convoy effect might lead to this being synchronized across the network, which would appear to users as the network dying every hour. The default timeout will be between 0 and 30 minutes unless specified.

Parameters:
NameTypeAttributesDescription
funcfunction

Function to wrap to execution later

maxtimenumber<optional>

Maximum timeout

Returns:
Type: 
function

(static) satisfiesDifficulty(buffer, difficulty) → {boolean}

Returns a boolean indicating if the supplied buffer meets the given difficulty requirement

Parameters:
NameTypeDescription
bufferbuffer

Buffer to check difficulty

difficultynumber

Number of leading zeroes

Returns:
Type: 
boolean

(static) toBinaryStringFromBuffer(buffer) → {string}

Converts a buffer to a string representation of binary

Parameters:
NameTypeDescription
bufferbuffer

Byte array to convert to binary string

Returns:
Type: 
string

(static) toPublicKeyHash(publicKey) → {buffer}

Takes a public key are returns the identity

Parameters:
NameTypeDescription
publicKeybuffer

Raw public key bytes

Returns:
Type: 
buffer

(static) validateLogger(logger)

Validates the given object is a logger

Parameters:
NameTypeDescription
loggerAbstractNode~logger

(static) validateStorageAdapter(storageAdapter)

Validates the given object is a storage adapter

Parameters:
NameTypeDescription
storageAdapterAbstractNode~storage

(static) validateTransport(transport)

Validates the given object is a transport

Parameters:
NameTypeDescription
transportAbstractNode~transport

Type Definitions

EquihashProof

Type:
  • object
Properties
NameTypeDescription
nnumber
knumber
noncenumber
valuebuffer