Classes

Node

Methods

(inner) knuthShuffle(array) → {array}

Shuffles an array in place.

Parameters:
NameTypeDescription
arrayarray

Array to shuffle

Returns:
Type: 
array

(inner) 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

Type Definitions

ExpirationStream

Reads objects from a module:kdns/node~ReadableStore and if an item should be expired, requests deletion.

Type:
Properties
NameTypeDescription
objectModeboolean

true

Fires:

NodeOptions

Overridable options passed to Node.

Type:
  • Object
Properties

ReadableStore

Type:
Properties
NameTypeDescription
objectModeboolean

true

ReplicatorStream

Reads objects from a module:kdns/node~ReadableStore and if an item should be replicated, performs an iterative store operation.

Type:
Properties
NameTypeDescription
objectModeboolean

StoredItem

Format of a storage entry.

Type:
  • Object
Properties
NameTypeDescription
blobbuffer

Raw bytes for the stored item

metaobject

Metadata needed for replication and expiration

Properties
NameTypeDescription
timestampDate

The time this item was stored

publisherstring

module:kdns/contacts~Contact fingerprint that stored this item