From 314ff871fcaf3ae9f76c6cfcc00bd8e3a4923bcc Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Thu, 3 Jan 2019 13:45:51 +0100 Subject: [PATCH] fix(core-p2p): malformed condition for filtering peers Currently we would leave in the list all peers that: "are not me or have invalid port or have invalid version" the intention must have been: "are not me and have valid port and have valid version". This change was first done in 0c2319649 and was later reverted in 109a4d311 with a scarce explanation: "it randomly causes issues". It is not clear what those issues were. However the current code is strikingly and obviously wrong - it would add peers that have invalid port, for example. So, fix the wrong code and followup by fixing any issues that arise, but not by resurrecting the wrong code. --- packages/core-p2p/src/monitor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core-p2p/src/monitor.ts b/packages/core-p2p/src/monitor.ts index cb0e337408..4f620e3e6a 100755 --- a/packages/core-p2p/src/monitor.ts +++ b/packages/core-p2p/src/monitor.ts @@ -843,7 +843,7 @@ export class Monitor implements P2P.IMonitor { } const filteredPeers: any[] = Object.values(peers).filter( - peer => !this.guard.isMyself(peer) || !this.guard.isValidPort(peer) || !this.guard.isValidVersion(peer), + peer => !this.guard.isMyself(peer) && this.guard.isValidPort(peer) && this.guard.isValidVersion(peer), ); for (const peer of filteredPeers) {