Skip to content

Commit

Permalink
improve peer discovery time, avoid connect on connection
Browse files Browse the repository at this point in the history
  • Loading branch information
paulo-ocean committed Jul 30, 2024
1 parent fc7320e commit e1d5b2f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion env.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Environmental variables are also tracked in `ENVIRONMENT_VARIABLES` within `src/
- `P2P_ipV6BindWsPort`: Port used on IPv6 WS connections. Defaults to `0` (Use whatever port is free. When running as docker, please set it explicitly). Example: `0`
- `P2P_ANNOUNCE_ADDRESSES`: List of addresses to announce to the network. Example: `"[\"/ip4/1.2.3.4/tcp/8000\"]"`
- `P2P_ANNOUNCE_PRIVATE`: Announce private IPs. Default: `True`
- `P2P_pubsubPeerDiscoveryInterval`: Interval (in ms) for discovery using pubsub. Defaults to `1000` (one second). Example: `1000`
- `P2P_pubsubPeerDiscoveryInterval`: Interval (in ms) for discovery using pubsub. Defaults to `3000` (three seconds). Example: `3000`
- `P2P_dhtMaxInboundStreams`: Maximum number of DHT inbound streams. Defaults to `500`. Example: `500`
- `P2P_dhtMaxOutboundStreams`: Maximum number of DHT outbound streams. Defaults to `500`. Example: `500`
- `P2P_mDNSInterval`: Interval (in ms) for discovery using mDNS. Defaults to `20000` (20 seconds). Example: `20000`
Expand Down
8 changes: 3 additions & 5 deletions src/components/P2P/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,9 @@ export class OceanP2P extends EventEmitter {
if (details) {
const peerId = details.detail
P2P_LOGGER.debug('Connection established to:' + peerId.toString()) // Emitted when a peer has been found
try {
this._libp2p.services.pubsub.connect(peerId.toString())
} catch (e) {}
} else {
/* empty */
// try {
// this._libp2p.services.pubsub.connect(peerId.toString())
// } catch (e) {}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ async function getEnvConfig(isStartup?: boolean): Promise<OceanNodeConfig> {
),
pubsubPeerDiscoveryInterval: getIntEnvValue(
process.env.P2P_pubsubPeerDiscoveryInterval,
1000
3000 // every 3 seconds
),
dhtMaxInboundStreams: getIntEnvValue(process.env.P2P_dhtMaxInboundStreams, 500),
dhtMaxOutboundStreams: getIntEnvValue(process.env.P2P_dhtMaxOutboundStreams, 500),
Expand Down

0 comments on commit e1d5b2f

Please sign in to comment.