Skip to content

Commit

Permalink
Counting the number of voters for removal was using an invalid loop
Browse files Browse the repository at this point in the history
  • Loading branch information
goldfire committed Oct 18, 2024
1 parent db3b821 commit 19da2bd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/democracy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 19da2bd

Please sign in to comment.