Interface Libp2pInit<T>

For Libp2p configurations and modules details read the Configuration Document.

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

Type Parameters

Properties

Addresses for transport listening and to advertise to the network

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

Type declaration

connectionGater: ConnectionGater

A connection gater can deny new connections based on user criteria

connectionManager: ConnectionManagerInit

libp2p Connection Manager configuration

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

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)[]

                      Type declaration

                      peerId: PeerId

                      peerId instance (it will be created if not provided)

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

                      Type declaration

                      libp2p PeerStore configuration

                      privateKey: PrivateKey<"Ed25519">

                      Private key associated with the peerId

                      services: ServiceFactoryMap<T>

                      Arbitrary libp2p modules

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

                      Type declaration

                      transportManager: TransportManagerInit

                      libp2p transport manager configuration

                      transports?: ((components) => Transport)[]

                      An array that must include at least 1 compliant transport

                      Type declaration

                      Methods