diff --git a/index.html b/index.html index 6335b511..34130b6b 100644 --- a/index.html +++ b/index.html @@ -1,8 +1,8 @@ - +
-Starts the libp2p node and all sub services
+Starts the libp2p node and all its subsystems
-(function (Error)
- = ()=>{}
)
-
- void
:
+ Promise<void>
:
@@ -1520,7 +1443,7 @@ if there is a handler. If not, errors will be logged.
Stop the libp2p node by closing its listeners and open connections
-(function (Error)
- = ()=>{}
)
-
- Dials to the provided peer. If successful, the PeerInfo
of the
-peer will be added to the nodes PeerBook
peerStore
-
+
@@ -1644,10 +1553,34 @@ peer will be added to the nodes PeerBook
PeerBook
void
:
+ Promise<Connection>
:
@@ -1685,7 +1618,7 @@ peer will be added to the nodes PeerBook
PeerBook
PeerBook
Dials to the provided peer and handshakes with the given protocol.
-If successful, the PeerInfo
of the peer will be added to the nodes PeerBook
,
+If successful, the PeerInfo
of the peer will be added to the nodes peerStore
,
and the Connection
will be sent in the callback
Connection
will be sent in the callback
Connection
will be sent in the callback
Connection
will be sent in the callback
void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Similar to dial
and dialProtocol
, but the callback will contain a
-Connection State Machine.
((PeerInfo | PeerId | Multiaddr | string))
- The peer to dial
-
- (string)
-
- (function (Error, ConnectionFSM))
-
- void
:
+ Promise<(Connection | any)>
:
@@ -1876,7 +1738,7 @@ Connection State Machine.
Disconnects from the given peer
+Disconnects all connections to the given peer
((PeerInfo | PeerId | Multiaddr | string))
- The peer to ping
+ peer (PeerId)
+ The PeerId to close connections to
(function (Error))
-
- void
:
+ Promise<void>
:
@@ -1962,7 +1816,7 @@ Connection State Machine.
Pings the provided peer
+Pings the given peer
- + @@ -2005,14 +1859,6 @@ Connection State Machine.(function (Error, Ping))
-
- void
:
+ Promise<number>
:
@@ -2044,39 +1890,30 @@ Connection State Machine.
Like new Libp2p(options)
except it will create a PeerInfo
-instance if one is not provided in options.
Registers the handler
for each protocol
(function (Error, Libp2p))
+ handler (function ({connection: any, stream: any, protocol: string}))
void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - Extends - - EventEmitter - -
- - - - - - - - - - -(any)
-
- (any)
-
- (any)
-
- Returns a list of the transports peerInfo has addresses for
- -(PeerInfo)
-
- Array<Transport>
:
-
-
-
-
-
@@ -2297,11 +1967,11 @@ instance if one is not provided in options.
Adds the handlerFunc
and matchFunc
to the Switch's protocol
-handler list for the given protocol
. If the matchFunc
returns
-true for a protocol check, the handlerFunc
will be called.
Removes the handler for each protocol. The protocol +will no longer be supported on streams.
-handlerFunc
will be called.
(string)
-
- (function (string, Connection))
-
- Removes the given protocol from the Switch's protocol list
- -(string)
-
- void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-If a muxed Connection exists for the given peer, it will be closed -and its reference on the Switch will be removed.
- -((PeerInfo | Multiaddr | PeerId))
-
- (function ())
-
- void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Returns whether or not the switch has any transports
- -boolean
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Issues a start on the Switch state.
- -(function
- = ()=>{}
)
- deprecated: Listening for the
-error
- and
-start
- events are recommended
-
- void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Issues a stop on the Switch state.
- -(function
- = ()=>{}
)
- deprecated: Listening for the
-error
- and
-stop
- events are recommended
-
- void
:
-
-
-
-
-
@@ -2802,2175 +2054,25 @@ and its reference on the Switch will be removed.
Creates an instance of Dialer.
- -(Swarm)
- the swarm
-
- (any)
- config options
-
- Dial the relays in the Addresses.Swarm config
- -(Array)
-
- void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Dial a peer over a relay
- - - - - - - - - - - - - -(multiaddr)
- the multiaddr of the peer to dial
-
- (Object)
- dial options
-
- (Function)
- a callback called once dialed
-
- Connection
:
- the connection
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Create a listener
- -(any)
-
- (Function)
-
- listener
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Filter check for all multiaddresses -that this transport can dial on
- -(any)
-
- Array<multiaddr>
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Creates an instance of Dialer.
- -(Swarm)
- the swarm
-
- (any)
- config options
-
- Helper that returns a relay connection
- -(any)
-
- (any)
-
- Function
:
- callback
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Dial a peer over a relay
- -(multiaddr)
- the multiaddr of the peer to dial
-
- (Function)
- a callback called once dialed
-
- Connection
:
- the connection
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Does the peer support the HOP protocol
- -(PeerInfo)
-
- (Function)
-
- void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Create a stream handler for connection
- - - - - - - - - - - - - -Read and decode message
- - - - - - - - - - - - - -(Function)
-
- (void | Function)
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Encode and write array of buffers
- - - - - - - - - - - - - -Function
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Get the raw Connection
- -(null | Connection | any)
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Return the handshake rest stream and invalidate handler
- -(any | {source, sink})
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Close the stream
- -undefined
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Get b58 string from multiaddr or peerinfo
- -((Multiaddr | PeerInfo))
-
- any
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Checks if peer has an existing connection
- - - - - - - - - - - - - -(String)
-
- (Swarm)
-
- Boolean
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Write a response
- -(StreamHandler)
-
- (CircuitRelay.Status)
-
- (Function)
-
- any
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Validate incomming HOP/STOP message
- -(CircuitRelay)
-
- (StreamHandler)
-
- (CircuitRelay.Type)
-
- (Function)
-
- any
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Add swarm handler and listen for incoming connections
- -(Multiaddr)
-
- (Function)
-
- void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Remove swarm listener
- -(Function)
-
- void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Get fixed up multiaddrs
-NOTE: This method will grab the peers multiaddrs and expand them such that:
-a) If it's an existing /p2p-circuit address for a specific relay i.e.
-/ip4/0.0.0.0/tcp/0/ipfs/QmRelay/p2p-circuit
this method will expand the
-address to /ip4/0.0.0.0/tcp/0/ipfs/QmRelay/p2p-circuit/ipfs/QmPeer
where
-QmPeer
is this peers id
-b) If it's not a /p2p-circuit address, it will encapsulate the address as a /p2p-circuit
-addr, such when dialing over a relay with this address, it will create the circuit using
-the encapsulated transport address. This is useful when for example, a peer should only
-be dialed over TCP rather than any other transport
(Function)
-
- void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Handle the incoming STOP message
- - - - - - - - - - - - - -({})
- the parsed protobuf message
-
- (StreamHandler)
- the stream handler wrapped connection
-
- (Function)
- callback
-
- undefined
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Construct a Circuit object
-This class will handle incoming circuit connections and -either start a relay or hand the relayed connection to -the swarm
- -(Swarm)
-
- (Object)
-
- Handle the relay message
- -(CircuitRelay)
-
- (StreamHandler)
-
- any
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Connect to STOP
- -(PeerInfo)
-
- (StreamHandler)
-
- (function)
-
- void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Negotiate STOP
- -(StreamHandler)
-
- (StreamHandler)
-
- (CircuitRelay)
-
- (function)
-
- void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Manages the transports for the switch. This simplifies dialing and listening across -multiple transports.
- -+ Type: + Circuit +
@@ -4982,19 +2084,6 @@ multiple transports. -(any)
-
- For a given transport, return its multiaddrs that match the given multiaddrs
+Like new Libp2p(options)
except it will create a PeerInfo
+instance if one is not provided in options.
(Transport)
-
- (Array<Multiaddr>)
-
- The protocols the IdentifyService supports
+ +Adds a Transport
to the list of transports on the switch, and assigns it to the given key
(String)
-
- (Transport)
-
- void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Closes connections for the given transport key -and removes it from the switch.
- - - - - - - - - - - - - -void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Calls remove
on each transport the switch has
(function (Error))
-
- void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-For a given transport key
, dial to all that transport multiaddrs
(PeerInfo)
-
- (function (Error, Connection))
-
- void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-For a given Transport key
, listen on all multiaddrs in the switch's _peerInfo
.
-If a handler
is not provided, the Switch's protocolMuxer
will be used.
(String)
-
- (any)
- Currently ignored
-
- (function (Connection))
-
- (function (Error))
-
- void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Closes the transport with the given key, by closing all of its listeners
- - - - - - - - - - - - - -void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-handler
is not provided, the Switch's protocolMuxer
-
- ourAddresses
+
+ findPeer
-
- src/switch/transport.js
+
+ src/peer-routing.js
Expand addresses in peer info into array of addresses with and without peer -ID suffix.
+Iterates over all peer routers in series to find the given peer.
- + @@ -5691,8 +2283,233 @@ ID suffix.Promise<PeerInfo>
:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Iterates over all content routers in series to find providers of the given key. +Once a content router succeeds, iteration will stop.
+ +(CID)
+ The CID key of the content to find
+
+ AsyncIterable<PeerInfo>
:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Iterates over all content routers in parallel to notify it is +a provider of the given key.
+ +(CID)
+ The CID key of the content to find
Promise<void>
:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Store the given key/value pair in the DHT.
+ + + + + + + + + + + + + +Promise<void>
:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Get the value to the given key. +Times out after 1 minute by default.
+ + + + + + + + + + + + + +(Buffer)
+
+ Promise<{from: PeerId, val: Buffer}>
:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Get the n
values to the given key without sorting.
Promise<Array<{from: PeerId, val: Buffer}>>
:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Subscribe the given handler to a pubsub topic
+ + + + + + + + + + + + + +void
:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Unsubscribes from a pubsub topic
+ + + + + + + + + + + + + +Publish messages to the given topics.
+ + + + + + + + + + + + + +Promise<void>
:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Get a list of topics the node is subscribed to.
+ + + + + + + + + + + + + + + + + +Array<String>
:
+ topics
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Get a list of the peer-ids that are subscribed to one topic.
+ + + + + + + + + + + + + +(string)
+
+ Array<string>
:
@@ -5734,21 +3259,23 @@ ID suffix.
Get the destination address of a (possibly relay) multiaddr as a string
+Converts the given peer
to a PeerInfo
instance.
+The PeerStore
will be checked for the resulting peer, and
+the peer will be updated in the PeerStore
.
(PeerStore)
String
:
+ PeerInfo
:
@@ -5807,21 +3342,22 @@ ID suffix.
Track dials per peer and limited them.
+If getPeerInfo
does not return a peer with multiaddrs,
+the libp2p
PeerRouter will be used to attempt to find the peer.
(number)
-
- Dial a list of multiaddrs on the given transport.
- -(PeerId)
-
- (SwarmTransport)
-
- (Array<Multiaddr>)
-
- Dial a single multiaddr on the given transport.
- -(PeerId)
-
- (SwarmTransport)
-
- (Multiaddr)
-
- (CancelToken)
-
- (function (Error, Connection))
-
- void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Queue up the amount of dials to a given peer.
- - - - - - - - - - - - - -Add new work to the queue.
- -(SwarmTransport)
-
- (Multiaddr)
-
- (CancelToken)
-
- (function (Error, Connection))
-
- void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-For a given multistream, registers to handle the given connection
- -(MultistreamDialer)
-
- (Connection)
-
- Promise
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-For a given multistream, selects the given protocol
- - - - - - - - - - - - - -(MultistreamDialer)
-
- (string)
-
- Promise
:
- Resolves the selected Connection
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Runs identify for the given connection and verifies it against the -PeerInfo provided
- -(Connection)
-
- (PeerInfo)
- The PeerInfo determined during crypto exchange
-
- Promise
:
- Resolves {peerInfo, observedAddrs}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Get unique values from arr
using getValue
to determine
-what is used for uniqueness
(Array)
- The array to get unique values for
-
- (function (value))
- The function to determine what is compared
-
- Array
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Contains methods for binding handlers to the Switch -in order to better manage its connections.
- -(any)
-
- Adds a listener for the given muxer
and creates a handler for it
-leveraging the Switch.protocolMuxer handler factory
(Muxer)
-
- void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Adds the encrypt
handler for the given tag
and also sets the
-Switch's crypto to passed encrypt
function
(String)
-
- (function (PeerID, Connection, PeerId, Callback))
-
- void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-If config.enabled is true, a Circuit relay will be added to the -available Switch transports.
- -(any)
-
- void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Sets identify to true on the Switch and performs handshakes -for libp2p-identify leveraging the Switch's muxer.
- -void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-- Type: - Object -
- - - - - - - - - - - - - -(Switch)
- : Our switch instance
-
-
- (PeerInfo)
- : The PeerInfo of the peer to dial
-
-
- (Muxer)
- : Optional - A muxed connection
-
-
- (Connection)
- : Optional - The base connection
-
-
- (string)
- : Optional - identify the connection as incoming or outgoing. Defaults to out.
-
-
- ConnectionFSM handles the complex logic of managing a connection -between peers. ConnectionFSM is internally composed of a state machine -to help improve the usability and debuggability of connections. The -state machine also helps to improve the ability to handle dial backoff, -coalescing dials and dial locks.
- -- Extends - - BaseConnection - -
- - - - - - - - - - -(ConnectionOptions)
-
- Name | -Description | -
---|---|
connectionOptions._switch any
- |
- - |
connectionOptions.peerInfo any
- |
- - |
connectionOptions.muxer any
- |
- - |
connectionOptions.conn any
- |
- - |
connectionOptions.type any
-
- (default 'out' )
- |
- - |
Puts the state into dialing mode
- -void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Initiates a handshake for the given protocol
- - - - - - - - - - - - - -(string)
- The protocol to negotiate
-
- (function (Error, Connection))
-
- void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Puts the state into muxing mode
- -void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Once a connection has been successfully dialed, the connection -will be privatized or encrypted depending on the presence of the -Switch.protector.
- -void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Event handler for disconnecting. Handles any needed cleanup
- -void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Analyses the given error, if it exists, to determine where the state machine -needs to go.
- -(Error)
-
- void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Event handler for state transition errors
- -(Error)
-
- void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-(DialRequest)
-
- Name | -Description | -
---|---|
dialRequest.peerInfo any
- |
- - |
dialRequest.protocol any
- |
- - |
dialRequest.options any
- |
- - |
dialRequest.callback any
- |
- - |
void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Starts the DialQueueManager
(function)
-
- Aborts all dials that are queued. This should -only be used when the Switch is being stopped
- -(function)
-
- Clears the denylist for a given peer
- -(PeerInfo)
-
- Attempts to establish a connection to the given peerInfo
at
-a lower priority than a standard dial.
(PeerInfo)
-
- (object)
-
- Name | -Description | -
---|---|
options.useFSM boolean
- |
- Whether or not to return a
-ConnectionFSM
-. Defaults to false.
- |
-
options.priority number
- |
- Lowest priority goes first. Defaults to 20. - | -
(function (Error, Connection))
-
- Adds the dial request to the queue for the given peerInfo
-The request will be added with a high priority (10).
Behaves like dial, except it calls back with a ConnectionFSM
- - - - - - - - - - - - - -(PeerInfo)
-
- (string)
-
- (function (Error, ConnectionFSM))
-
- (object)
+
+ Name | +Description | +
---|---|
options.maxConnections Number
+ |
+ The maximum number of connections allowed. Default=Infinity + | +
options.minConnections Number
+ |
+ The minimum number of connections to avoid pruning. Default=0 + | +
options.maxData Number
+ |
+ The max data (in and out), per average interval to allow. Default=Infinity + | +
options.maxSentData Number
+ |
+ The max outgoing data, per average interval to allow. Default=Infinity + | +
options.maxReceivedData Number
+ |
+ The max incoming data, per average interval to allow.. Default=Infinity + | +
options.maxEventLoopDelay Number
+ |
+ The upper limit the event loop can take to run. Default=Infinity + | +
options.pollInterval Number
+ |
+ How often, in milliseconds, metrics and latency should be checked. Default=2000 + | +
options.movingAverageInterval Number
+ |
+ How often, in milliseconds, to compute averages. Default=60000 + | +
options.defaultPeerValue Number
+ |
+ The value of the peer. Default=1 + | +
Allows the DialQueueManager
to execute dials
Starts the Connection Manager. If Metrics are not enabled on libp2p +only event loop and connection limits will be monitored.
Iterates over all items in the DialerQueue -and executes there callback with an error.
-This causes the entire DialerQueue to be drained
+Stops the Connection Manager
Adds the dialRequest
to the queue and ensures queue is running
Sets the value of the given peer. Peers with lower values +will be disconnected first.
-Name | -Description | -
---|---|
dialRequest.peerInfo any
- |
- - |
dialRequest.protocol any
- |
- - |
dialRequest.options any
- |
- - |
dialRequest.callback any
- |
- - |
void
:
-
-
-
-
-
@@ -8607,73 +3773,21 @@ and executes there callback with an error.
Will execute up to MAX_PARALLEL_DIALS
dials
Tracks the incoming connection and check the connection limit
-Will remove the peerInfo
from the dial denylist
(PeerInfo)
+ connection (Connection)
Returns the Queue
for the given peerInfo
Removes the connection from tracking
-(PeerInfo)
+ connection (Connection)
Queue
:
-
-
-
-
-
@@ -8797,193 +3903,21 @@ and executes there callback with an error.
Components required to execute a dial
+Creates an instance of Circuit.
-- Type: - Object -
- - - - - - - - - - - - - -(PeerInfo)
- : The peer to dial to
-
-
- (string?)
- : The protocol to create a stream for
-
-
- - Type: - Object -
- - - - - - - - - - - - - -(ConnectionFSM)
-
-
- (boolean)
-
-
- Attempts to create a new connection or stream (when muxed),
-via negotiation of the given protocol
. If no protocol
is
-provided, no action will be taken and callback
will be called
-immediately with no error or values.
string
+ Libp2p
ConnectionFSM
- function (Error, Connection)
+ Upgrader
Dial a peer over a relay
+ +(multiaddr)
+ the multiaddr of the peer to dial
+
+ (Object)
+ dial options
+
+ Name | +Description | +
---|---|
options.signal AbortSignal?
+ |
+ An optional abort signal + | +
void
:
+ Connection
:
+ the connection
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Create a listener
+ + + + + + + + + + + + + +(any)
+
+ (Function)
+
+ listener
:
@@ -9082,22 +4189,21 @@ immediately with no error or values.
A convenience array wrapper for controlling -a per peer queue
+Filter check for all Multiaddrs that this transport can dial on
- + @@ -9114,29 +4220,12 @@ a per peer queue -(Switch)
-
- (function (string))
- Called when the queue stops
-
- Queue
:
+ Array<Multiaddr>
:
@@ -9159,14 +4248,84 @@ a per peer queue
- (any)
+
+ Listener
:
+ a transport listener
+
+
+
+
+
+
+
+
+
+
+ Adds the dial request to the queue. The queue is not automatically started
+Add swarm handler and listen for incoming connections
- +(string)
-
- (boolean)
- If callback should use a ConnectionFSM instead
-
- Starts the queue. If the queue was started true
will be returned.
-If the queue was already running false
is returned.
boolean
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Stops the queue
- -Stops the queue and errors the callback for each dial request
- -Marks the queue as denylisted. The queue will be immediately aborted.
- -false
is returned.
+Get fixed up multiaddrs
+NOTE: This method will grab the peers multiaddrs and expand them such that:
+a) If it's an existing /p2p-circuit address for a specific relay i.e.
+/ip4/0.0.0.0/tcp/0/ipfs/QmRelay/p2p-circuit
this method will expand the
+address to /ip4/0.0.0.0/tcp/0/ipfs/QmRelay/p2p-circuit/ipfs/QmPeer
where
+QmPeer
is this peers id
+b) If it's not a /p2p-circuit address, it will encapsulate the address as a /p2p-circuit
+addr, such when dialing over a relay with this address, it will create the circuit using
+the encapsulated transport address. This is useful when for example, a peer should only
+be dialed over TCP rather than any other transport
Array<Multiaddr>
:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
false
is returned.
+
+
@@ -9578,21 +4554,22 @@ If the queue was already running false
is returned.
Takes a transport key and returns a connection handler function
+Performs a HOP request to a relay peer, to request a connection to another +peer. A new, virtual, connection will be created between the two via the relay.
-false
is returned.
(function)
- A custom handler to use
+ Name | +Description | +
---|---|
options.connection Connection
+ |
+ Connection to the relay + | +
options.request any
+ |
+ + |
options.circuit Circuit
+ |
+ + |
false
is returned.
function (Connection)
:
- A connection handler function
+ Promise<Connection>
:
+
@@ -9661,21 +4669,21 @@ If the queue was already running false
is returned.
Takes a base connection and manages listening behavior
+Write a response
-false
is returned.
(Connection)
- The connection to manage
-
+ streamHandler (StreamHandler)
+
+ (CircuitRelay.Status)
+
false
is returned.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Validate incomming HOP/STOP message
+ +(any)
+ A CircuitRelay unencoded protobuf message
+
+ (StreamHandler)
+
+ Create a stream handler for connection
+ +Read and decode message
+ +void
:
@@ -9725,6 +4967,132 @@ If the queue was already running false
is returned.
+Encode and write array of buffers
+ +(any)
+ An unencoded CircuitRelay protobuf message
+
+ Return the handshake rest stream and invalidate handler
+ +any
:
+ A duplex iterable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
false
is returned.
-
- src/switch/connection/base.js
+
+ src/circuit/circuit/stream-handler.js
Puts the state into its disconnecting flow
+Close the stream
-void
:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ false
is returned.
Name | +Description | +
---|---|
$0.transportManager any
+ |
+ + |
$0.peerStore any
+ |
+ + |
$0.concurrency any
+
+ (default MAX_PARALLEL_DIALS )
+ |
+ + |
$0.timeout any
+
+ (default DIAL_TIMEOUT )
+ |
+ + |
$0.perPeerLimit any
+
+ (default MAX_PER_PEER_DIALS )
+ |
+ + |
(object)
+
+ Name | +Description | +
---|---|
options.transportManager TransportManager
+ |
+ + |
options.concurrency number
+ |
+ Number of max concurrent dials. Defaults to
+MAX_PARALLEL_DIALS
+ |
+
options.timeout number
+ |
+ How long a dial attempt is allowed to take. Defaults to
+DIAL_TIMEOUT
+ |
+
(Peerstore)
+
+ Clears any pending dials
+ +Connects to the first success of a given list of Multiaddr
. addrs
should
+include the id of the peer being dialed, it will be used for encryption verification.
((Array<Multiaddr> | Multiaddr))
+
+ (object?
+ = {}
)
+
+ Name | +Description | +
---|---|
options.signal AbortSignal?
+ |
+ An AbortController signal + | +
false
is returned.
void
:
+ Promise<Connection>
:
@@ -9809,384 +5509,23 @@ If the queue was already running false
is returned.
Gets the current state of the connection
+Connects to a given PeerInfo
or PeerId
by dialing all of its known addresses.
+The dial to the first address that is successfully able to upgrade a connection
+will be used.
string
:
- The current state of the connection
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Puts the state into encrypting mode
- -void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Puts the state into privatizing mode
- -void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Puts the state into muxing mode
- -void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Event handler for disconnected.
- -void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Event handler for privatized
- -void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Creates a pull stream to run the given Connection stream through -the given Observer. This provides a way to more easily monitor connections -and their metadata. A new Connection will be returned that contains -has the attached Observer.
- -(Transport)
-
+ peerId (PeerId)
+ The remote peer id to dial
+
(Connection)
-
- Name | +Description | +
---|---|
options.signal AbortSignal?
+ |
+ An AbortController signal + | +
Promise<Connection>
:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Manages running the dialAction
on multiple provided addrs
in parallel
+up to a maximum determined by the number of tokens returned
+from dialer.getTokens
. Once a DialRequest is created, it can be
+started using DialRequest.run(options)
. Once a single dial has succeeded,
+all other dials in the request will be cancelled.
(object)
+
+ Name | +Description | +
---|---|
options.signal AbortSignal
+ |
+ An AbortController signal + | +
An encryption stub in the instance that the default crypto -has not been overriden for the Switch
- -Takes a Switch and returns an Observer that can be used in conjunction with
-observe-connection.js. The returned Observer comes with incoming
and
-outgoing
properties that can be used in pull streams to emit all metadata
-for messages that pass through a Connection.
Must be called for stats to saved. Any data pushed for tracking +will be ignored.
+ +Stops all averages timers and prevents new data from being tracked.
+Once stop
is called, start
must be called to resume stats tracking.
Gets the global Stats
object
EventEmitter
:
+ Stats
:
@@ -10398,23 +6103,82 @@ for messages that pass through a Connection.
Binds to message events on the given observer
to generate stats
-based on the Peer, Protocol and Transport used for the message. Stat
-events will be emitted via the update
event.
Returns a list of PeerId
strings currently being tracked
Array<string>
:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Returns the Stats
object for the given PeerId
whether it
+is a live peer, or in the disconnected peer LRU cache.
update
event.
(Observer)
-
- (any)
+ peerId (PeerId)
update
event.
+
+
+
+
+
+ Returns a list of all protocol strings currently being tracked.
+ +Array<string>
:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Returns the Stats
object for the given protocol
.
(string)
+
+ Stats
:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Should be called when all connections to a given peer
+have closed. The Stats
collection for the peer will
+be stopped and moved to an LRU for temporary retention.
(PeerId)
+
+ Replaces the PeerId
string with the given peerId
.
+If stats are already being tracked for the given peerId
, the
+placeholder stats will be merged with the existing stats.
(string)
+ A peerId string
+
+ (PeerId)
+
+ Tracks data running through a given Duplex Iterable stream
. If
+the peerId
is not provided, a placeholder string will be created and
+returned. This allows lazy tracking of a peer when the peer is not yet known.
+When the PeerId
is known, Metrics.updatePlaceholder
should be called
+with the placeholder string returned from here, and the known PeerId
.
(Object)
+
+ Name | +Description | +
---|---|
options.stream {sink: function (any), source: function ()}
+ |
+ A duplex iterable stream + | +
options.protocol string?
+ |
+ The protocol the stream is running + | +
options.peerId PeerId?
+ |
+ The id of the remote peer that's connected + | +
options.remotePeer any
+ |
+ + |
string
:
+ The peerId string or placeholder string
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Merges other
into target
. target
will be modified
+and returned.
Stats
:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Creates and returns a Least Recently Used Cache
+ +(Number)
+
+ LRUCache
:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
update
event.
-
- src/switch/stats/stat.js
+
+ src/metrics/stats.js
update
event.
@@ -10630,8 +6945,8 @@ should only need to be called if Stats.stop
was previously called,
@@ -10695,8 +7010,8 @@ timer.
@@ -10759,8 +7074,8 @@ timer.
@@ -10804,6 +7119,70 @@ timer.
+Returns a plain JSON object of the stats
+ +any
:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Creates and returns a Least Recently Used Cache
- -(Number)
-
- LRUCache
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Iterates over all peer routers in series to find the given peer.
- -(String)
- The id of the peer to find
-
- (object)
@@ -11043,9 +7339,18 @@ current Timestamp, then resets the update timer.
number
+ Libp2p
Upgrader
+ Adds a Transport
to the manager
(Transport)
Iterates over all content routers in series to find providers of the given key. -Once a content router succeeds, iteration will stop.
+Stops all listeners
-Dials the given Multiaddr over it's supported transport
+ +(CID)
- The CID key of the content to find
-
+ ma (Multiaddr)
+
Promise<Connection>
:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns all Multiaddr's the listeners are using
+ +Array<Multiaddr>
:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Returns all the transports instances.
+ +Iterator<Transport>
:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Finds a transport that matches the given Multiaddr
+ +(Multiaddr)
+
+ (Transport | null)
:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Starts listeners for each given Multiaddr.
+ +(Array<Multiaddr>)
+
+ Removes the given transport from the manager. +If a transport has any running listeners, they will be closed.
+ +(string)
+
+ Removes all transports from the manager. +If any listeners are running, they will be closed.
+ +(Object)
number
+ any
number
+ any
any
+ any
+ any
+
+ (default ()=>{}
)
+ any
+
+ (default ()=>{}
)
+ (function)
+
+
+ (AsyncIterator)
+
+
+ (any)
+
+
+ (Multiaddr)
+
+
+ Upgrades an inbound connection
+ +(MultiaddrConnection)
+
+ Promise<Connection>
:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Upgrades an outbound connection
+ +(MultiaddrConnection)
+
+ Promise<Connection>
:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+(Object)
+
+ Name | +Description | +
---|---|
$0.localPeer any
+ |
+ + |
$0.metrics any
+ |
+ + |
$0.cryptos any
+ |
+ + |
$0.muxers any
+ |
+ + |
$0.onConnectionEnd any
+
+ (default ()=>{} )
+ |
+ + |
$0.onConnection any
+
+ (default ()=>{} )
+ |
+
Name | +Description | +
---|---|
$0.peerStore any
+ |
+ + |
(Object)
+
+ Map of connections per peer +TODO: this should be handled by connectionManager
+ +Map of topologies
+ +Cleans up the registrar
+ +Add a new connected peer to the record +TODO: this should live in the ConnectionManager
+ +(PeerInfo)
+
+ (Connection)
+
+ void
:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Remove a disconnected peer from the record +TODO: this should live in the ConnectionManager
+ +(PeerInfo)
+
+ (Connection)
+
+ (Error?)
+
+ void
:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Get a connection with a peer.
+ +(PeerInfo)
+
+ Connection
:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Register handlers for a set of multicodecs given
+ +(Topology)
+ protocol topology
+
+ string
:
+ registrar identifier
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Unregister topology.
+ + + + + + + + + + + + + +(string)
+ registrar identifier
+
+ boolean
:
+ unregistered successfully
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Ping a given peer and wait for its response, getting the operation latency.
+ + + + + + + + + + + + + +(Libp2p)
+
+ (PeerInfo)
+
+ Promise<Number>
:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Subscribe ping protocol handler.
+ +(Libp2p)
+
+ Unsubscribe ping protocol handler.
+ +(Libp2p)
+
+ (object)
+
+ Name | +Description | +
---|---|
options.registrar Registrar
+ |
+ + |
options.protocols Map<string, handler>
+ |
+ A reference to the protocols we support + | +
options.peerInfo PeerInfo
+ |
+ The peer running the identify service + | +
Send an Identify Push update to the list of connections
+ + + + + + + + + + + + + +(Array<Connection>)
+
+ Promise<void>
:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Calls push
for all peers in the peerStore
that are connected
(PeerStore)
+
+ Requests the Identify
message from peer associated with the given connection
.
+If the identified peer does not match the PeerId
associated with the connection,
+an error will be thrown.
(Connection)
+
+ Promise<void>
:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+A handler to register with Libp2p to process identify messages.
+ + + + + + + + + + + + + +Promise<void>
:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Replaces the multiaddrs on the given peerInfo
,
+with the provided multiaddrs
Replaces the protocols on the given peerInfo
,
+with the provided protocols
Takes the addr
and converts it to a Multiaddr if possible
(Multiaddr | null)
: