Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3652 from LiskHQ/3643-seed_discovery
Browse files Browse the repository at this point in the history
Discovery is too reliant on seed peers - Closes #3643
  • Loading branch information
MaciejBaj authored May 17, 2019
2 parents 0312196 + 06b47a5 commit 8ac5068
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions elements/lisk-p2p/src/p2p.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,17 +552,15 @@ export class P2P extends EventEmitter {
this._peerPool.selectPeersAndConnect([...this._newPeers.values()]);
}

private async _startDiscovery(
knownPeers: ReadonlyArray<P2PDiscoveredPeerInfo> = [],
): Promise<void> {
private async _startDiscovery(): Promise<void> {
if (this._discoveryIntervalId) {
throw new Error('Discovery is already running');
}
this._discoveryIntervalId = setInterval(async () => {
await this._discoverPeers(knownPeers);
await this._discoverPeers([...this._triedPeers.values()]);
}, this._discoveryInterval);

await this._discoverPeers(knownPeers);
await this._discoverPeers([...this._triedPeers.values()]);
}

private _stopDiscovery(): void {
Expand Down Expand Up @@ -643,7 +641,7 @@ export class P2P extends EventEmitter {
}
});

await this._startDiscovery(seedPeerInfos);
await this._startDiscovery();
}

public async stop(): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion elements/lisk-p2p/test/integration/p2p.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ describe('Integration tests for P2P library', () => {
describe('Peer discovery', () => {
it('should discover all peers in the network after a few cycles of discovery', async () => {
// Wait for a few cycles of discovery.
await wait(DISCOVERY_INTERVAL * 5);
await wait(DISCOVERY_INTERVAL * 7);

p2pNodeList.forEach(p2p => {
const { connectedPeers } = p2p.getNetworkStatus();
Expand Down

0 comments on commit 8ac5068

Please sign in to comment.