new Protocol(router, extensionsopt)
Name | Type | Attributes | Description |
---|---|---|---|
router | module:kdns/router~Router | Routing table to use | |
extensions | Object.<string, function()> | <optional> | Additional custom RPC handlers to include |
- Source
Members
events
Exposes events arising from handling protocol messages. Some of these events may require handling if they pass a Protocol~HandlerResponse
Name | Type | Description |
---|---|---|
events | EventEmitter |
- Source
router
PropertiesName | Type | Description |
---|---|---|
router | module:kdns/router~Router |
- Source
Methods
FIND_NODE(key, contact, respond)
The FIND_NODE RPC includes a 160-bit key. The recipient of the RPC returns up to K contacts that it knows to be closest to the key. The recipient must return K contacts if at all possible. It may only return fewer than K if it is returning all of the contacts that it has knowledge of.
Name | Type | Description |
---|---|---|
key | string | 160 bit ID to search for |
contact | module:kdns/contacts~Contact | The peer who originated this RPC |
respond | module:kdns/protocol~HandlerResponse | Callback function for responding to RPC |
- Source
FIND_VALUE(key, contact, respond)
A FIND_VALUE RPC includes a B=160-bit key. If a corresponding value is present on the recipient, the associated data is returned. Otherwise the RPC is equivalent to a FIND_NODE and a set of K contacts is returned.
Name | Type | Description |
---|---|---|
key | string | 160 bit ID to search for |
contact | module:kdns/contacts~Contact | The peer who originated this RPC |
respond | module:kdns/protocol~HandlerResponse | Callback function for responding to RPC |
- Source
PING(contact, respond)
This RPC involves one node sending a PING message to another, which presumably replies with a PONG. This has a two-fold effect: the recipient of the PING must update the bucket corresponding to the sender; and, if there is a reply, the sender must update the bucket appropriate to the recipient.
Name | Type | Description |
---|---|---|
contact | module:kdns/contacts~Contact | The peer who originated this RPC |
respond | module:kdns/protocol~HandlerResponse | Callback function for responding to RPC |
- Source
STORE(key, item, contact, respond)
The sender of the STORE RPC provides a key and a block of data and requires that the recipient store the data and make it available for later retrieval by that key.
Name | Type | Description |
---|---|---|
key | string | 160 bit ID to address this blob by |
item | module:kdns/node~StoredItem | Blob and metadata to store |
contact | module:kdns/contacts~Contact | The peer who originated this RPC |
respond | module:kdns/protocol~HandlerResponse | Callback function for responding to RPC |
- Source
Events
storage_get
- Source
storage_put
- Source