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

fix!: do not auto-dial peers #1397

Merged
merged 3 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions examples/libp2p-in-the-browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ document.addEventListener('DOMContentLoaded', async () => {
libp2p.addEventListener('peer:discovery', (evt) => {
const peer = evt.detail
log(`Found peer ${peer.id.toString()}`)

// dial them when we discover them
libp2p.dial(evt.detail.id).catch(err => {
log(`Could not dial ${evt.detail.id}`, err)
})
})

// Listen for new connections to peers
Expand Down
2 changes: 1 addition & 1 deletion examples/peer-and-content-routing/1.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const createNode = async () => {
])

// The DHT routing tables need a moment to populate
await delay(100)
await delay(1000)

const peer = await node1.peerRouting.findPeer(node3.peerId)

Expand Down
5 changes: 5 additions & 0 deletions examples/webrtc-direct/dialer.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ document.addEventListener('DOMContentLoaded', async () => {
// Listen for new peers
libp2p.addEventListener('peer:discovery', (evt) => {
log(`Found peer ${evt.detail.id.toString()}`)

// dial them when we discover them
libp2p.dial(evt.detail.id).catch(err => {
log(`Could not dial ${evt.detail.id}`, err)
})
})

// Listen for new connections to peers
Expand Down
65 changes: 0 additions & 65 deletions src/connection-manager/dialer/auto-dialer.ts

This file was deleted.

15 changes: 0 additions & 15 deletions src/libp2p.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { PeerRecordUpdater } from './peer-record-updater.js'
import { DHTPeerRouting } from './dht/dht-peer-routing.js'
import { PersistentPeerStore } from '@libp2p/peer-store'
import { DHTContentRouting } from './dht/dht-content-routing.js'
import { AutoDialer } from './connection-manager/dialer/auto-dialer.js'
import { Initializable, Components, isInitializable } from '@libp2p/components'
import type { PeerId } from '@libp2p/interface-peer-id'
import type { Connection } from '@libp2p/interface-connection'
Expand Down Expand Up @@ -238,20 +237,6 @@ export class Libp2pNode extends EventEmitter<Libp2pEvents> implements Libp2p {
...init.ping
}))

const autoDialer = this.configureComponent(new AutoDialer(this.components, {
enabled: init.connectionManager.autoDial !== false,
minConnections: init.connectionManager.minConnections,
dialTimeout: init.connectionManager.dialTimeout ?? 30000
}))

this.addEventListener('peer:discovery', evt => {
if (!this.isStarted()) {
return
}

autoDialer.handle(evt)
})

// Discovery modules
for (const service of init.peerDiscovery ?? []) {
this.configureComponent(service)
Expand Down