new Bucket()
Extends
- Map
Members
head
PropertiesName | Type | Description |
---|---|---|
head | Array.<string, module:kdns/contacts~Contact> | The contact at the bucket head |
length
PropertiesName | Type | Description |
---|---|---|
length | number | The number of contacts in the bucket |
tail
PropertiesName | Type | Description |
---|---|---|
tail | Array.<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:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
key | string | | 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 |
Returns:
- Type:
- Array.<string, module:kdns/contacts~Contact>
indexOf(key) → {number}
Returns the index of the given node id
Parameters:
Name | Type | Description |
---|---|---|
key | string | 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:
Name | Type | Description |
---|---|---|
nodeId | string | The identity key for the contact |
contact | module:kdns/contacts~Contact | The address information for the contact |
Returns:
index
- Type:
- number