Constructor
new AbstractNode(options)
Contructs the primary interface for a kad node
Name | Type | Description | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | object | Properties
|
- Source
Methods
listen()
Passes through to the AbstractNode~transport
- Source
plugin(plugin)
Accepts an arbitrary function that receives this node as context for mounting protocol handlers and extending the node with other methods
Name | Type | Description |
---|---|---|
plugin | function |
- Source
receive(request, response)
Processes a the given arguments by sending them through the appropriate middleware stack
Name | Type | Description |
---|---|---|
request | AbstractNode~request | |
response | AbstractNode~response |
- Source
send(method, params, contact, callbackopt) → {Promise.<(object|array), Error>}
Sends the [method, params] to the contact and executes the handler on response or timeout
Name | Type | Attributes | Description |
---|---|---|---|
method | string | RPC method name | |
params | object | | RPC parameters | |
contact | Bucket~contact | Destination address information | |
callback | AbstractNode~sendCallback | <optional> |
- Source
- Type:
- Promise.<(object|array), Error>
use(methodopt, middleware)
Mounts a message handler route for processing incoming RPC messages
Name | Type | Attributes | Description |
---|---|---|---|
method | string | <optional> | RPC method name to route through |
middleware | AbstractNode~middleware |
- Source
(inner) responseError(errorMessage, errorCodeopt)
Name | Type | Attributes | Description |
---|---|---|---|
errorMessage | string | Text describing the error encountered | |
errorCode | number | <optional> | Error code |
- Source
(inner) responseSend(results)
Name | Type | Description |
---|---|---|
results | array | | Result parameters to respond with |
- Source
Type Definitions
logger
- object
Name | Type | Description |
---|---|---|
debug | function | Passed string of debug information |
info | function | Passed string of general information |
warn | function | Passed string of warnings |
error | function | Passed string of error message |
- Source
middleware(erroropt, request, response, next)
Name | Type | Attributes | Description |
---|---|---|---|
error | error | <optional> | Error object resulting from a middleware |
request | AbstractNode~request | The incoming message object | |
response | AbstractNode~response | The outgoing response object | |
next | AbstractNode~next | Call to proceed to next middleware |
- Source
next(error)
Name | Type | Description |
---|---|---|
error | error | | Indicates to exit the middleware stack |
- Source
request
PropertiesName | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
contact | array | Peer who sent this request Properties
| |||||||||
params | array | | Method parameters (varies by method) | |||||||||
method | string | Method name being called |
- Source
response
PropertiesName | Type | Description |
---|---|---|
send | AbstractNode~responseSend | |
error | AbstractNode~responseError |
- Source
sendCallback(error, result)
Name | Type | Description |
---|---|---|
error | null | | |
result | object | |
- Source
sendError
PropertiesName | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
message | string | Error description | |||||||||||||||
type | string | Error type | |||||||||||||||
request | object | Request the error is from Properties
|
- Source
storage
Implements a subset of the LevelUP interface
- object
Name | Type | Description |
---|---|---|
get | function | |
put | function | |
del | function | |
createReadStream | function |
- Source
transport
- object
Name | Type | Description |
---|---|---|
read | function | Returns raw message buffer if available |
write | function | Passed raw message buffer |
- Source
Events
error
Error event fires when a critical failure has occurred; if no handler is specified, then it will throw
- Error
- Source
join
Join event is triggered when the routing table is no longer empty
- Source