Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Libp2pBindingOptions

Options provided by the libp2p communication binding.

Hierarchy

  • CommunicationBindingOptions
    • Libp2pBindingOptions

Index

Properties

Optional bootstrapPeers

bootstrapPeers: string[]

Provide a list of libp2p bootstrap nodes for peer discovery by specifying their multiaddresses (optional).

This option may be specified in addition to the default Multicast DNS peer discovery mechanism. It is useful to connect to remote peers in non-local networks that are known in advance and that are not discoverable by mDNS.

A typical bootstrap multiaddr specifies a bootstrap node by its given transport multiaddr composed with its libp2p peer ID multiaddr, like this: /ip4/7.7.7.7/tcp/4242/p2p/QmYyQSo1c1Ym7orWxLYvCrM2EmxFTANf8wXmmE7DWjhx5N.

Optional listenAddresses

listenAddresses: string[]

A list of transport multiaddresses on which the libp2p node should listen (optional).

If not specified, the libp2p node will listen on the first local IPv4 network interface, using a randomly chosen free port. If no such interface is present, it will listen on the first IPv6 interface.

remarks

Only TCP multiaddrs are supported, e.g. use /ip4/127.0.0.1/tcp/2000 to configure the node to listen on TCP port 2000 on the IPv4 loopback interface.

remarks

To listen on all available IPv4 and/or IPv6 network interfaces using a randomly chosen free port, specify the following multiaddresses: /ip4/0.0.0.0/tcp/0, /ip6/::1/tcp/0.

remarks

To listen on host names instead of TCP addresses, use the dns4 format to specify multiaddresses: /dns4/foo.mydomain.com/tcp/6001.

remarks

If your agents run in docker compose services, use the dns4 format instead of ip4 or ip6 to specify multiaddresses: /dns4/<docker-service-name>/tcp/6001.

Optional logLevel

logLevel: CommunicationBindingLogLevel

The level used to log errors, informational, as well as debug messages generated by the binding (optional).

Messages corresponding to the specified log level are emitted on the "error", "info", or "debug" event, respectively. If level is "error", only errors are emitted; if level is "info", only "error" and "info" messages are emitted; if level is "debug", all messages are emitted.

If not specified, the log level defaults to "error".

Optional namespace

namespace: string

Namespace used to isolate different Coaty applications running with the same binding type in the same networking infrastructure (optional).

Communication events are only routed between agents within a common communication namespace: an agent publishes and observes communication events with respect to the given namespace.

If not specified (i.e. undefined), a default namespace named "-" is used.

remarks

The libp2p binding poses the following restrictions on this option: namespace must not include consecutive dots or end with a dot, and namespace must not contain more than 236 characters.

Optional ownBootstrapAddresses

ownBootstrapAddresses: string[]

Provide a list of transport multiaddrs on the local host that should make up a bootstrap peer (optional).

This option is used to set up a bootstrap peer which listens on the given transport addresses (a +n explicit port must be specified). The transport part of a multiaddr specified in the correlating option bootstrapPeers should correspond with one of the given addresses.

A typical bootstrap transport multiaddr on the local host looks like: /ip4/127.0.0.1/tcp/4242.

remarks

Only TCP multiaddrs are supported. Note that you have to provide a constant, preconfigured peer ID for a bootstrap peer (with options peerId) so that the peer is discoverable by other peers specifying this peer ID in their bootstrap addresses.

Optional peerDiscoveryInterval

peerDiscoveryInterval: number

The interval in milliseconds to discover remote peers or broadcast peer information (optional).

If not specifid, the value defaults to 10000 msecs.

remarks

This option is used by both peer discovery methods: mDNS and bootstrap peers.

Optional peerId

peerId: { id: string; privKey: string; pubKey: string }

Use a specific libp2p Peer ID consisting of the ID's multihash complete with public/private keypair (optional).

If no Peer ID is specified, a new one is generated automatically whenever the binding joins the libp2p network.

Provide a specific/constant Peer ID whenever you want to leverage known addresses, for example in combination with bootstrap peer discovery (see options ownBootstrapAddresses and bootstrapPeers).

remarks

To generate a new Peer ID complete with private/public keypairs, npm install peer-id and use either the CLI function peer-id or require("peer-id").create().then(id => console.log(id.toJSON())). Details can be found here.

Type declaration

  • id: string

    The multihash of the public key as string.

  • privKey: string

    RSA Private Key.

  • pubKey: string

    RSA PublicKey.

Optional peerSettlingTimeWindow

peerSettlingTimeWindow: number

The time window (in milliseconds) to wait on start-up of the libp2p node until no more subscriptions by other peers are received (optional). Afterwards, own publication messages are delivered to other peers.

If not specified, the settling time window defaults to 1000ms.

If a lot of agents are started concurrently, the settling time window should be enlarged.

Optional shouldDisableMdnsPeerDiscovery

shouldDisableMdnsPeerDiscovery: boolean

Disable Multicast DNS (mDNS) as peer discovery method (optional).

If not specified, mDNS peer discovery is enabled by default.

Optional shouldEnableCrossNamespacing

shouldEnableCrossNamespacing: boolean

The libp2p binding does not support this option, i.e. it is always disabled. Coaty communication events published by agents in a different namespace cannot be observed.

Determines whether to enable cross-namespace communication between agents in special use cases (optional).

If true, an agent receives communication events published by any agent running with the same binding type in the same networking infrastructure, regardless of namespace.

If not specified or false, this option is not enabled.

Generated using TypeDoc