Class: Bucket

Bucket

Represents a column of the routing table holding up to K contacts

new Bucket()

Source:

Members


Properties:
Name Type Description
head object The contact at the bucket head
Source:

length

Properties:
Name Type Description
length number The number of contacts in the bucket
Source:

tail

Properties:
Name Type Description
tail object The contact at the bucket tail
Source:

Methods


getClosestToKey(key [, count] [, exclusive])

Returns an array of contacts in the bucket that are closest to the given key
Parameters:
Name Type Argument Default Description
key string | buffer Reference key for finding other contacts
count number <optional>
constants.K Max results to return
exclusive boolean <optional>
false Exclude result matching the key exactly
Source:
Returns:
Type
array

indexOf(key)

Returns the index of the given node id
Parameters:
Name Type Description
key string Node identity key for getting index
Source:
Returns:
Type
number

set(nodeId, contact)

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:
Name Type Description
nodeId string The identity key for the contact
contact object The address information for the contact
Source:
Returns:
index
Type
number

Type Definitions


contact

Type:
  • array
Properties:
Name Type Description
0 string Node identity key
1 object Contact information (varies by plugins)
Source: