Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(docs): dialer config instructions incorrect/outdated #1645

Closed
SgtPooki opened this issue Mar 22, 2023 · 2 comments
Closed

bug(docs): dialer config instructions incorrect/outdated #1645

SgtPooki opened this issue Mar 22, 2023 · 2 comments
Labels
need/triage Needs initial labeling and prioritization

Comments

@SgtPooki
Copy link
Member

see

#### Configuring Dialing
Dialing in libp2p can be configured to limit the rate of dialing, and how long dials are allowed to take. The dialer configuration object should have the following properties:
| Name | Type | Description |
|------|------|-------------|
| maxParallelDials | `number` | How many multiaddrs we can dial in parallel. |
| maxAddrsToDial | `number` | How many multiaddrs is the dial allowed to dial for a single peer. |
| maxDialsPerPeer | `number` | How many multiaddrs we can dial per peer, in parallel. |
| dialTimeout | `number` | Second dial timeout per peer in ms. |
| resolvers | `object` | Dial [Resolvers](https://github.com/multiformats/js-multiaddr/blob/master/src/resolvers/index.js) for resolving multiaddrs |
| addressSorter | `(Array<Address>) => Array<Address>` | Sort the known addresses of a peer before trying to dial. |
| startupReconnectTimeout | `number` | When a node is restarted, we try to connect to any peers marked with the `keep-alive` tag up until to this timeout in ms is reached (default: 60000) |
The below configuration example shows how the dialer should be configured, with the current defaults:
```js
import { createLibp2p } from 'libp2p'
import { tcp } from '@libp2p/tcp'
import { mplex } from '@libp2p/mplex'
import { noise } from '@chainsafe/libp2p-noise'
import { dnsaddrResolver } from '@multiformats/multiaddr/resolvers'
import { publicAddressesFirst } from '@libp2p-utils/address-sort'
const node = await createLibp2p({
transports: [tcp()],
streamMuxers: [mplex()],
connectionEncryption: [noise()],
dialer: {
maxParallelDials: 100,
maxAddrsToDial: 25,
maxDialsPerPeer: 4,
dialTimeout: 30e3,
resolvers: {
dnsaddr: dnsaddrResolver
},
addressSorter: publicAddressesFirst
}
```

However, Libp2pInit.dialer doesn't exist:

image

@SgtPooki SgtPooki added the need/triage Needs initial labeling and prioritization label Mar 22, 2023
@maschad
Copy link
Member

maschad commented Mar 24, 2023

Thanks for this @SgtPooki the docs are definitely a bit out of date 😓 That being said, all those configurations moved to the ConnectionManager config during the conversion to Typescript PR and I am not sure why. Maybe @achingbrain can explain.

I actually have an unrelated PR in draft which would move them back to the DialerConfig

@achingbrain
Copy link
Member

achingbrain commented Mar 24, 2023

Maybe @achingbrain can explain.

As ever, just trying to reduce the number of moving parts that are exposed to consumers.

libp2p.dial calls connectionManager.openConnection, which calls the dialler.

Internal components also call connectionManager.openConnection.

Thus, the connection manager is in charge of opening and closing connections - if you call the dialler directly then the connection manager is no longer in charge of managing connections, so, if you like, the dialler is an internal component of the connection manager, consequently the dialling related settings are passed to the connection manager and the dialler is just an internal implementation detail.

@maschad maschad closed this as completed May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need/triage Needs initial labeling and prioritization
Projects
None yet
Development

No branches or pull requests

3 participants