kdns/bucket~ Bucket

Extends

  • Map

Members

Properties
NameTypeDescription
headArray.<string, module:kdns/contacts~Contact>

The contact at the bucket head

length

Properties
NameTypeDescription
lengthnumber

The number of contacts in the bucket

tail

Properties
NameTypeDescription
tailArray.<string, module:kdns/contacts~Contact>

The contact at the bucket tail

Methods

getClosestToKey(key, countopt, exclusiveopt) → {Array.<string, module:kdns/contacts~Contact>}

Returns an array of contacts in the bucket that are closest to the given key

Parameters:
NameTypeAttributesDefaultDescription
keystring | buffer

Reference key for finding other contacts

countnumber<optional>
constants.K

Max results to return

exclusiveboolean<optional>
false

Exclude result matching the key exactly

Returns:
Type: 
Array.<string, module:kdns/contacts~Contact>

indexOf(key) → {number}

Returns the index of the given node id

Parameters:
NameTypeDescription
keystring

Node identity key for getting index

Returns:
Type: 
number

set(nodeId, contact) → {number}

Sets the contact to the node ID in the bucket if it is not full; if the bucket already contains the contact, move it to the tail - otherwise we place it at the head

Parameters:
NameTypeDescription
nodeIdstring

The identity key for the contact

contactmodule:kdns/contacts~Contact

The address information for the contact

Returns:

index

Type: 
number