Members
head
PropertiesName | Type | Description |
---|---|---|
head | object | The contact at the bucket head |
length
PropertiesName | Type | Description |
---|---|---|
length | number | The number of contacts in the bucket |
tail
PropertiesName | Type | Description |
---|---|---|
tail | object | The contact at the bucket tail |
Methods
getClosestToKey(key, countopt, exclusiveopt) → {array}
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
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 | object | The address information for the contact |
Returns:
index
- Type:
- number
Type Definitions
contact
Type:
Properties- array
Name | Type | Description |
---|---|---|
0 | string | Node identity key |
1 | object | Contact information (varies by plugins) |