Interface Libp2pInit<T>

For Libp2p configurations and modules details read the Configuration Document.

interface Libp2pInit<T> {
    addresses?: AddressManagerInit;
    connectionEncrypters?: ((components) => ConnectionEncrypter<unknown>)[];
    connectionGater?: ConnectionGater;
    connectionManager?: ConnectionManagerInit;
    connectionMonitor?: ConnectionMonitorInit;
    contentRouters?: ((components) => ContentRouting)[];
    datastore?: Datastore<{}, {}, {}, {}, {}, {}, {}, {}, {}, {}>;
    dns?: DNS;
    logger?: ComponentLogger;
    nodeInfo?: NodeInfo;
    peerDiscovery?: ((components) => PeerDiscovery)[];
    peerRouters?: ((components) => PeerRouting)[];
    peerStore?: PersistentPeerStoreInit;
    privateKey?: PrivateKey;
    services?: ServiceFactoryMap<T>;
    streamMuxers?: ((components) => StreamMuxerFactory)[];
    transportManager?: TransportManagerInit;
    transports?: ((components) => Transport<ProgressEvent<any, unknown>>)[];
    connectionProtector?(components): ConnectionProtector;
    metrics?(components): Metrics;
}

Type Parameters

Properties

addresses?: AddressManagerInit

Addresses for transport listening and to advertise to the network

connectionEncrypters?: ((components) => ConnectionEncrypter<unknown>)[]

Connection encrypters ensure that data sent over connections cannot be eavesdropped on, and that the remote peer posesses the private key that corresponds to the public key that it's Peer ID is derived from.

Type declaration

connectionGater?: ConnectionGater

A connection gater can deny new connections based on user criteria

connectionManager?: ConnectionManagerInit

libp2p Connection Manager configuration

connectionMonitor?: ConnectionMonitorInit

libp2p Connection Monitor configuration

contentRouters?: ((components) => ContentRouting)[]

Content routers provide implementations for content routing queries

Type declaration

datastore?: Datastore<{}, {}, {}, {}, {}, {}, {}, {}, {}, {}>

An optional datastore to persist peer information, DHT records, etc.

An in-memory datastore will be used if one is not provided.

Type declaration

    Type declaration

      Type declaration

        Type declaration

          Type declaration

            Type declaration

              Type declaration

                Type declaration

                  Type declaration

                    Type declaration

                      dns?: DNS

                      An optional DNS resolver configuration. If omitted the default DNS resolver for the platform will be used which means node:dns on Node.js and DNS-JSON-over-HTTPS for browsers using Google and Cloudflare servers.

                      An optional logging implementation that can be used to write runtime logs.

                      Set the DEBUG env var or the debug key on LocalStorage to see logs.

                      Example

                      Node.js:

                      $ DEBUG="*libp2p:*" node myscript.js
                      

                      Browsers:

                      localStorage.setItem('debug', '*libp2p:*')
                      
                      nodeInfo?: NodeInfo

                      Metadata about the node - implementation name, version number, etc

                      peerDiscovery?: ((components) => PeerDiscovery)[]

                      Peer discovery mechanisms allow finding peers on the network

                      Type declaration

                      peerRouters?: ((components) => PeerRouting)[]

                      Peer routers provide implementations for peer routing queries

                      Type declaration

                      libp2p PeerStore configuration

                      privateKey?: PrivateKey

                      The private key is used in cryptographic operations and the Peer ID derived from it's corresponding public key is used to identify the node to other peers on the network.

                      If this is not passed a new Ed25519 private key will be generated.

                      services?: ServiceFactoryMap<T>

                      Arbitrary libp2p modules

                      streamMuxers?: ((components) => StreamMuxerFactory)[]

                      Stream muxers allow the creation of many data streams over a single connection.

                      Type declaration

                      transportManager?: TransportManagerInit

                      libp2p transport manager configuration

                      transports?: ((components) => Transport<ProgressEvent<any, unknown>>)[]

                      Transports are low-level communication channels

                      Type declaration

                      Methods