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
Name | Type | Description |
---|---|---|
b1 | buffer | Buffer to compare |
b2 | buffer | Buffer to compare |
- Type:
- number
(static) generatePrivateKey() → {buffer}
Generates a private key
- Type:
- buffer
(static) getBucketIndex(referenceKey, foreignKey) → {number}
Calculate the index of the bucket that key would belong to
Name | Type | Description |
---|---|---|
referenceKey | string | Key to compare |
foreignKey | string | Key to compare |
- Type:
- number
(static) getContactURL(contact) → {string}
Returns a stringified URL from the supplied contact object
Name | Type | Description |
---|---|---|
contact | Bucket~contact |
- Type:
- string
(static) getDistance(key1, key2) → {buffer}
Calculate the distance between two keys
Name | Type | Description |
---|---|---|
key1 | string | Identity key to compare |
key2 | string | Identity key to compare |
- Type:
- buffer
(static) getPowerOfTwoBufferForIndex(referenceKey, bucketIndex) → {buffer}
Returns a buffer with a power-of-two value given a bucket index
Name | Type | Description |
---|---|---|
referenceKey | string | | Key to find next power of two |
bucketIndex | number | Bucket index for key |
- Type:
- buffer
(static) getRandomBufferInBucketRange(referenceKey, index)
Generate a random number within the bucket's range
Name | Type | Description |
---|---|---|
referenceKey | buffer | Key for bucket distance reference |
index | number | Bucket index for random buffer selection |
(static) getRandomKeyBuffer() → {buffer}
Returns a random valid key/identity as a buffer
- Type:
- buffer
(static) getRandomKeyString() → {string}
Returns a random valid key/identity as a string
- Type:
- string
(static) hash160(input)
Returns the RMD-160 hash of the input
Name | Type | Description |
---|---|---|
input | buffer | Data to hash |
(static) hash256(input)
Returns the SHA-256 hash of the input
Name | Type | Description |
---|---|---|
input | buffer | Data to hash |
(static) isCompatibleVersion(version) → {boolean}
Returns whether or not the supplied semver tag is compatible
Name | Type | Description |
---|---|---|
version | string | The semver tag from the contact |
- Type:
- boolean
(static) isHexaString(str) → {boolean}
Tests if a string is valid hex
Name | Type | Description |
---|---|---|
str | string |
- Type:
- boolean
(static) isValidContact(contact, loopback) → {boolean}
Determines if the supplied contact is valid
Name | Type | Description |
---|---|---|
contact | Bucket~contact | The contact information for a given peer |
loopback | boolean | Allows contacts that are localhost |
- Type:
- boolean
(static) keyBufferIsValid(key) → {boolean}
Determines if the given buffer key is valid
Name | Type | Description |
---|---|---|
key | buffer | Node ID or item key |
- Type:
- boolean
(static) keyStringIsValid(key) → {boolean}
Determines if the given string key is valid
Name | Type | Description |
---|---|---|
key | string | Node ID or item key |
- Type:
- boolean
(static) parseContactURL() → {object}
Returns a parsed contact object from a URL
- 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.
Name | Type | Attributes | Description |
---|---|---|---|
func | function | Function to wrap to execution later | |
maxtime | number | <optional> | Maximum timeout |
- Type:
- function
(static) satisfiesDifficulty(buffer, difficulty) → {boolean}
Returns a boolean indicating if the supplied buffer meets the given difficulty requirement
Name | Type | Description |
---|---|---|
buffer | buffer | Buffer to check difficulty |
difficulty | number | Number of leading zeroes |
- Type:
- boolean
(static) toBinaryStringFromBuffer(buffer) → {string}
Converts a buffer to a string representation of binary
Name | Type | Description |
---|---|---|
buffer | buffer | Byte array to convert to binary string |
- Type:
- string
(static) toPublicKeyHash(publicKey) → {buffer}
Takes a public key are returns the identity
Name | Type | Description |
---|---|---|
publicKey | buffer | Raw public key bytes |
- Type:
- buffer
(static) validateLogger(logger)
Validates the given object is a logger
Name | Type | Description |
---|---|---|
logger | AbstractNode~logger |
(static) validateStorageAdapter(storageAdapter)
Validates the given object is a storage adapter
Name | Type | Description |
---|---|---|
storageAdapter | AbstractNode~storage |
(static) validateTransport(transport)
Validates the given object is a transport
Name | Type | Description |
---|---|---|
transport | AbstractNode~transport |
Type Definitions
EquihashProof
- object
Name | Type | Description |
---|---|---|
n | number | |
k | number | |
nonce | number | |
value | buffer |