libp2p
    Preparing search index...

    Interface Libp2pInit<T>

    For Libp2p configurations and modules details read the Configuration Document.

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

    Type Parameters

    Index

    Properties

    addresses?: AddressManagerInit

    Addresses for transport listening and to advertise to the network

    connectionEncrypters?: ((components: Components) => ConnectionEncrypter)[]

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

    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: Components) => ContentRouting)[]

    Content routers provide implementations for content routing queries

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

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

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

    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.

    Node.js:

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

    Browsers:

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

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

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

    Peer discovery mechanisms allow finding peers on the network

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

    Peer routers provide implementations for peer routing queries

    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: Components) => StreamMuxerFactory)[]

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

    transportManager?: TransportManagerInit

    libp2p transport manager configuration

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

    Transports are low-level communication channels

    Methods