Libp2p node.
Sets or gets the default captureRejection value for all emitters.
This symbol shall be used to install a listener for only monitoring 'error'
events. Listeners installed using this symbol are called before the regular
'error'
listeners are called.
Installing a listener using this symbol does not change the behavior once an
'error'
event is emitted, therefore the process will still crash if no
regular 'error'
listener is installed.
Gets a Map of the current connections. The keys are the stringified
PeerId
of the peer. The value is an array of Connections to that peer.
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.
The peer to dial
Will dial to the given peerId
if the current number of
connected peers is less than the configured ConnectionManager
minConnections.
Called when libp2p has started and before it returns
Called whenever peer discovery services emit peer
events.
Known peers may be emitted.
Initializes and starts peer discovery services
Dials to the provided peer. If successful, the known metadata of the
peer will be added to the nodes peerStore
The peer to dial
Dials 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.
The peer to dial
Overrides EventEmitter.emit to conditionally emit errors if there is a handler. If not, errors will be logged.
Registers the handler
for each protocol
Disconnects all connections to the given peer
the peer to close connections to
Load keychain keys from the datastore. Imports the private key as 'self', if needed.
Pings the given peer in order to obtain the operation latency.
The peer to ping
Starts the libp2p node and all its subsystems
Stop the libp2p node by closing its listeners and open connections
Removes the handler for each protocol. The protocol will no longer be supported on streams.
Like new Libp2p(options)
except it will create a PeerId
instance if one is not provided in options.
Libp2p configuration options
{Connection} connection
{MuxedStream} stream
{string} protocol
{boolean} [enabled = false]
{number} [queriesPerPeriod = 1]
{number} [interval = 300e3]
{number} [timeout = 10e3]
{boolean} [enabled = false]
{number} [kBucketSize = 20]
{RandomWalkOptions} [randomWalk]
{boolean} [clientMode]
{import('libp2p-interfaces/src/types').DhtSelectors} [selectors]
{import('libp2p-interfaces/src/types').DhtValidators} [validators]
{Datastore} [datastore]
{boolean} persistence
{boolean} enabled
{boolean} enabled
{boolean} [enabled = true]
{import('./circuit').RelayAdvertiseOptions} [advertise]
{import('./circuit').HopOptions} [hop]
{import('./circuit').AutoRelayOptions} [autoRelay]
{DhtOptions} [dht] dht module options
{import('./nat-manager').NatManagerOptions} [nat]
{Record<string, Object|boolean>} [peerDiscovery]
{PubsubLocalOptions & PubsubOptions} [pubsub] pubsub module options
{RelayOptions} [relay]
{Record<string, Object>} [transport] transport options indexed by transport key
{TransportFactory[]} transport
{MuxerFactory[]} streamMuxer
{Crypto[]} connEncryption
{PeerDiscoveryModule[]} [peerDiscovery]
{PeerRoutingModule[]} [peerRouting]
{ContentRoutingModule[]} [contentRouting]
{Object} [dht]
{{new(...args: any[]): Pubsub}} [pubsub]
{Protector} [connProtector]
{Libp2pModules} modules libp2p modules to use
{import('./address-manager').AddressManagerOptions} [addresses]
{import('./connection-manager').ConnectionManagerOptions} [connectionManager]
{Datastore} [datastore]
{import('./dialer').DialerOptions} [dialer]
{import('./identify/index').HostProperties} [host] libp2p host
{KeychainOptions & import('./keychain/index').KeychainOptions} [keychain]
{MetricsOptions & import('./metrics').MetricsOptions} [metrics]
{import('./peer-routing').PeerRoutingOptions} [peerRouting]
{PeerStoreOptions & import('./peer-store/persistent').PersistentPeerStoreOptions} [peerStore]
{import('./transport-manager').TransportManagerOptions} [transportManager]
{Libp2pConfig} [config]
{PeerId} peerId
{PeerId} [peerId]
Libp2p#error Emitted when an error occurs
Libp2p#peer:discovery Emitted when a peer is discovered