The content routing subsystem allows the user to find providers for content, let the network know they are providers for content, and get/put values to the DHT.
The logger used by this libp2p node
Optional
metricsThe metrics subsystem allows recording values to assess the health/performance of the running node.
The PeerId is a unique identifier for a node on the network.
It is the hash of an RSA public key or, for Ed25519 or secp256k1 keys, the key itself.
The peer routing subsystem allows the user to find peers on the network or to find peers close to binary keys.
The peer store holds information we know about other peers on the network.
A set of user defined services
The current status of the libp2p node
Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.
The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.
When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.
When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.
When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
Optional
options: boolean | AddEventListenerOptionsOptional
afterIf implemented, this method will be invoked after the start method.
All other components will have had their start method invoked before this method is called.
Optional
afterIf implemented, this method will be invoked after the stop method.
All other components will have had their stop method invoked before this method is called.
Optional
beforeIf implemented, this method will be invoked before the start method.
It should not assume any other components have been started.
Optional
beforeIf implemented, this method will be invoked before the stop method.
Any other components will still be running when this method is called.
Dials to the provided peer. If successful, the known metadata of the
peer will be added to the nodes peerStore
.
If a PeerId is passed as the first argument, the peer will need to have known multiaddrs for it in the PeerStore.
Optional
options: DialOptionsDials to the provided peer and tries to handshake with the given protocols in order.
If successful, the known metadata of the peer will be added to the nodes peerStore
,
and the MuxedStream
will be returned together with the successful negotiated protocol.
Optional
options: DialProtocolOptionsDispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
Return a list of all connections this node has open, optionally filtering by a PeerId
Optional
peerId: PeerIdReturn the list of dials currently in progress or queued to start
Get a deduplicated list of peer advertising multiaddrs by concatenating the listen addresses used by transports with any configured announce addresses as well as observed addresses reported by peers.
If Announce addrs are specified, configured listen addresses will be ignored though observed addresses will still be included.
Return a list of all peers we currently have a connection open to
Returns the public key for the passed PeerId. If the PeerId is of the 'RSA' type this may mean searching the routing if the peer's key is not present in the peer store.
Optional
options: AbortOptionsOptional
options: AbortOptionsOptional
options: AbortOptionsOptional
options: AbortOptionsOptional
options: AbortOptionsSets up multistream-select routing of protocols to their application handlers. Whenever a stream is opened on one of the provided protocols, the handler will be called. handle
must be called in order to register a handler and support for a given protocol. This also informs other peers of the protocols you support.
libp2p.handle(protocols, handler, options)
In the event of a new handler for the same protocol being added and error
will be thrown. Pass force: true
to override this.
Optional
options: StreamHandlerOptionsAttempts to gracefully close an open connection to the given peer. If the connection is not closed in the grace period, it will be forcefully closed.
An AbortSignal can optionally be passed to control when the connection is forcefully closed.
Optional
options: AbortOptionsGiven the current node configuration, returns a promise of true
or
false
if the node would attempt to dial the passed multiaddr.
This means a relevant transport is configured, and the connection gater would not block the dial attempt.
This may involve resolving DNS addresses so you should pass an AbortSignal.
Optional
options: IsDialableOptionsRemoves the event listener in target's event listener list with the same type, callback, and options.
Optional
listener: null | EventHandler<Libp2pEvents<T>[K]>Optional
options: boolean | EventListenerOptionsRemoves the event listener in target's event listener list with the same type, callback, and options.
Optional
listener: EventHandler<Event>Optional
options: boolean | EventListenerOptionsOptional
detail: CustomEventInit<Detail>This method will be invoked to start the component.
It should not assume that any other components have been started.
This method will be invoked to stop the component.
It should not assume any other components are running when it is called.
Removes the handler for each protocol. The protocol will no longer be supported on streams.
Libp2p nodes implement this interface.