Optional
logger?: LoggerOptional
options?: Partial<NodesOptions>Optional
seedReadonly
[initReadonly
connectionReadonly
connectionAlpha constant for kademlia The number of the closest nodes to contact initially
Readonly
connectionInitial delay between punch packets, delay doubles each attempt.
Readonly
connectionTime to wait to garbage collect un-used node connections.
Readonly
connectionTime interval for sending keep alive messages.
Readonly
connectionTime to keep alive node connection.
Protected
connectionProtected
connectionsData structure to store all NodeConnections. If a connection to a node n does not exist, no entry for n will exist in the map. Alternatively, if a connection is currently being instantiated by some thread, an entry will exist in the map, but only with the lock (no connection object). Once a connection is instantiated, the entry in the map is updated to include the connection object. A nodeIdString is used for the key here since NodeIds can't be used to properly retrieve a value from the map.
Protected
keyProtected
loggerProtected
nodeProtected
quicProtected
quicProtected
quicReadonly
rpcDefault timeout for RPC handlers
Readonly
rpcMax parse buffer size before RPC parser throws an parse error.
Protected
rpcProtected
seedProtected
tlsFor usage with withF, to acquire a connection This unique acquire function structure of returning the ResourceAcquire itself is such that we can pass targetNodeId as a parameter (as opposed to an acquire function with no parameters).
Id of target node to communicate with
Optional
ctx: Partial<ContextTimed>ResourceAcquire Resource API for use in with contexts
Protected
addAdds connection to the connections map. Preforms some checks and lifecycle hooks. This code is shared between the reverse and forward connection creation.
Protected
destroyRemoves the connection from the connection man and destroys it.
Id of node we are destroying connection to
Protected
establishProtected
This will connect to the provided address looking for any of the listed nodes. Locking is not handled at this level, it must be handled by the caller.
Protected
establishUsed internally by getMultiConnection to attempt a single connection. Locking is not done at this stage, it must be done at a higher level. This will do the following...
Will attempt to find a connection via a Kademlia search. The connection will be established in the process.
Id of the node we are tying to find
Optional
pingTimeoutTime: numbertimeout for any ping attempts
Optional
ctx: Partial<ContextTimed>Attempts to locate a target node in the network (using Kademlia). Adds all discovered, active nodes to the current node's database (up to k discovered nodes). Once the target node is found, the method returns and stops trying to locate other nodes.
Ultimately, attempts to perform a "DNS resolution" on the given target node ID (i.e. given a node ID, retrieves the node address, containing its IP and port).
ID of the node attempting to be found (i.e. attempting to find its IP address and port)
Optional
pingTimeoutTime: numberOptional
ctx: Partial<ContextTimed>whether the target node was located in the process
Protected
getThis will return an existing connection or establish a new one as needed. If no address is provided it will preform a kademlia search for the node.
Optional
address: NodeAddressOptional
ctx: Partial<ContextTimed>Protected
getThis gets a connection with a known address.
Id of node we are creating connection to.
The address to connect on if specified. If not provided we attempt a kademlia search.
Optional
ctx: Partial<ContextTimed>ConnectionAndLock that was created or exists in the connection map
Protected
getUsed to start connections to multiple nodes and hosts at the same time. The main use-case is to connect to multiple seed nodes on the same hostname.
Optional
limit: numberOptional
ctx: Partial<ContextTimed>Protected
handleProtected
handleProtected
handleTriggers the destruction of the NodeConnectionManager
. Since this is only in
response to an underlying problem or close it will force destroy.
Dispatched by the EventNodeConnectionManagerError
event as the
EventNodeConnectionManagerError
-> EventNodeConnectionManagerClose
event path.
Protected
handleDispatches a EventNodeConnectionManagerClose
in response to any NodeConnectionManager
error event. Will trigger stop of the NodeConnectionManager
via the
EventNodeConnectionManagerError
-> EventNodeConnectionManagerClose
event path.
Protected
handleProtected
handleRedispatches QUICSOcket
or QUICServer
error events as NodeConnectionManager
error events.
This should trigger the destruction of the NodeConnection
through the
EventNodeConnectionError
-> EventNodeConnectionClose
event path.
Protected
handleProtected
handleProtected
handleOpen up a port in the NAT by sending packets to the target address. The packets will be sent in an exponential backoff dialing pattern and contain random data.
This can't know it succeeded, it will continue until timed out or cancelled.
Protected
initiateThis attempts the NAT hole punch procedure. It will return a
PromiseCancellable
that will resolve once the procedure times out, is
cancelled or the other end responds.
This is pretty simple, it will contact all known seed nodes and get them to relay a punch signal message.
Note: Avoid using a large set of target nodes, It could trigger a large amount of pings to a single target.
Optional
ctx: Partial<ContextTimedInput>Returns true if the given node is a seed node.
Checks if a connection can be made to the target. Returns true if the connection can be authenticated, it's certificate matches the nodeId and the addresses match if provided. Otherwise, returns false.
Forwards a received hole punch message on to the target. If not known, the node ID -> address mapping is attempted to be discovered through Kademlia (note, however, this is currently only called by a 'broker' node).
the original relay message (assumed to be created in nodeConnection.start())
Optional
ctx: Partial<ContextTimed>Performs an RPC request to send a hole-punch message to the target. Used to initially establish the NodeConnection from source to target.
node ID of the relay node (i.e. the seed node)
node ID of the current node (i.e. the sender)
node ID of the target node to hole punch
Optional
address: NodeAddressOptional
ctx: Partial<ContextTimed>Perform some function on another node over the network with a connection. Will either retrieve an existing connection, or create a new one if it doesn't exist. for use with normal arrow function
Id of target node to communicate with
Function to handle communication
Optional
ctx: Partial<ContextTimedInput>Perform some function on another node over the network with a connection. Will either retrieve an existing connection, or create a new one if it doesn't exist. for use with a generator function
Id of target node to communicate with
Generator function to handle communication
Optional
ctx: Partial<ContextTimed>Generated using TypeDoc
Time used to establish
NodeConnection