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
OptionalmetricsThe 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
The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.
Optionaloptions: boolean | AddEventListenerOptionsOptionalafterIf 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.
OptionalafterIf 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.
OptionalbeforeIf implemented, this method will be invoked before the start method.
It should not assume any other components have been started.
OptionalbeforeIf 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.
Optionaloptions: 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.
Optionaloptions: DialProtocolOptionsThe dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().
The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().
Return a list of all connections this node has open, optionally filtering by a PeerId
OptionalpeerId: 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.
Optionaloptions: AbortOptionsOptionaloptions: AbortOptionsOptionaloptions: AbortOptionsOptionaloptions: AbortOptionsOptionaloptions: 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.
Optionaloptions: 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.
Optionaloptions: 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.
Optionaloptions: IsDialableOptionsRegister a topology to be informed when peers are encountered that support the specified protocol
Optionaloptions: AbortOptionsThe removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.
Optionallistener: EventHandler<Libp2pEvents<T>[K]> | nullOptionaloptions: boolean | EventListenerOptionsThe removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.
Optionallistener: EventHandler<Event>Optionaloptions: boolean | EventListenerOptionsOptionaldetail: 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.
Optionaloptions: AbortOptionsRegisters one or more middleware implementations that will be invoked for incoming and outgoing protocol streams that match the passed protocol.
Libp2p nodes implement this interface.