From ed65af608bfb5569b2881507ff82cf1ee2b2c57a Mon Sep 17 00:00:00 2001 From: Jonathan Gros-Dubois Date: Thu, 16 May 2019 16:39:24 +0200 Subject: [PATCH 1/2] Use triedPeers instead of seedpeers for each discovery round --- elements/lisk-p2p/src/p2p.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/elements/lisk-p2p/src/p2p.ts b/elements/lisk-p2p/src/p2p.ts index 82a3d1b15ff..c98cdb5db4b 100644 --- a/elements/lisk-p2p/src/p2p.ts +++ b/elements/lisk-p2p/src/p2p.ts @@ -552,17 +552,15 @@ export class P2P extends EventEmitter { this._peerPool.selectPeersAndConnect([...this._newPeers.values()]); } - private async _startDiscovery( - knownPeers: ReadonlyArray = [], - ): Promise { + private async _startDiscovery(): Promise { 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 { @@ -643,7 +641,7 @@ export class P2P extends EventEmitter { } }); - await this._startDiscovery(seedPeerInfos); + await this._startDiscovery(); } public async stop(): Promise { From 06b47a5a40f97274d5962438ad5bcc2debb88798 Mon Sep 17 00:00:00 2001 From: Jonathan Gros-Dubois Date: Thu, 16 May 2019 17:27:12 +0200 Subject: [PATCH 2/2] Give a bit more time to perform discovery --- elements/lisk-p2p/test/integration/p2p.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elements/lisk-p2p/test/integration/p2p.ts b/elements/lisk-p2p/test/integration/p2p.ts index c22cfa8a5da..8f86c25b72e 100644 --- a/elements/lisk-p2p/test/integration/p2p.ts +++ b/elements/lisk-p2p/test/integration/p2p.ts @@ -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();