From 19da2bde7aea6978cc992d755365947cfb11e814 Mon Sep 17 00:00:00 2001 From: James Simpson Date: Thu, 17 Oct 2024 19:44:56 -0500 Subject: [PATCH] Counting the number of voters for removal was using an invalid loop --- lib/democracy.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/democracy.js b/lib/democracy.js index 93613fe..6427199 100644 --- a/lib/democracy.js +++ b/lib/democracy.js @@ -389,11 +389,11 @@ class Democracy extends EventEmitter { let numVoters = 0; // Count the number of voters that haven't been marked for election. - for (let i = 0; i < this._nodes.length; i += 1) { - if (this._nodes[i] && !this._nodes[i].voters.length) { + Object.keys(this._nodes).forEach((id) => { + if (this._nodes[id] && !this._nodes[id].voters.length && this._nodes[id].state != 'removed') { numVoters += 1; } - } + }); // If we have concensus, remove this node from the list. if (node.voters.length >= numVoters) {