-
Notifications
You must be signed in to change notification settings - Fork 447
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The autodialer is a feature from an older time when the DHT was less reliable and we didn't have things like the random walk component. There's not a lot of benefit in opening connections to any old peer, instead protocols now have better ways of targetting the kind of peers they require. Actively dialing peers harms platforms where connections are extremely expensive such as react-native so this feature has been removed. Closes #2621 Fixes #2418 BREAKING CHANGE: the autodialer has been removed as well as the corresponding config keys --------- Co-authored-by: Russell Dempsey <[email protected]>
- Loading branch information
1 parent
0d20426
commit ab90179
Showing
32 changed files
with
532 additions
and
937 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* eslint-env mocha */ | ||
|
||
import { KEEP_ALIVE, type Libp2p } from '@libp2p/interface' | ||
import { expect } from 'aegir/chai' | ||
import { createLibp2p } from 'libp2p' | ||
import pWaitFor from 'p-wait-for' | ||
import { createBaseOptions } from './fixtures/base-options.js' | ||
|
||
describe('peers', () => { | ||
let nodes: Libp2p[] | ||
|
||
beforeEach(async () => { | ||
nodes = await Promise.all([ | ||
createLibp2p(createBaseOptions()), | ||
createLibp2p(createBaseOptions()), | ||
createLibp2p(createBaseOptions()) | ||
]) | ||
}) | ||
|
||
afterEach(async () => Promise.all(nodes.map(async n => { await n.stop() }))) | ||
|
||
it('should redial a peer tagged with KEEP_ALIVE', async () => { | ||
await nodes[0].dial(nodes[1].getMultiaddrs()) | ||
|
||
expect(nodes[0].getConnections(nodes[1].peerId)).to.not.be.empty() | ||
|
||
await nodes[0].peerStore.merge(nodes[1].peerId, { | ||
tags: { | ||
[KEEP_ALIVE]: { | ||
value: 1 | ||
} | ||
} | ||
}) | ||
|
||
await Promise.all( | ||
nodes[0].getConnections(nodes[1].peerId).map(async conn => conn.close()) | ||
) | ||
|
||
await pWaitFor(async () => { | ||
return nodes[0].getConnections(nodes[1].peerId).length > 0 | ||
}, { | ||
interval: 100, | ||
timeout: { | ||
milliseconds: 5000, | ||
message: 'Did not reconnect to peer tagged with KEEP_ALIVE' | ||
} | ||
}) | ||
}) | ||
|
||
it('should store the multiaddr for a peer after a successful dial', async () => { | ||
await nodes[0].dial(nodes[1].getMultiaddrs()) | ||
|
||
expect(nodes[0].getConnections(nodes[1].peerId)).to.not.be.empty() | ||
|
||
const peer = await nodes[0].peerStore.get(nodes[1].peerId) | ||
expect(peer.addresses).to.not.be.empty() | ||
expect(peer.metadata.get('last-dial-success')).to.be.ok() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.