From 4cd8ee2c97844b3d7198d1f6ed3c51b4ed598b96 Mon Sep 17 00:00:00 2001 From: Lev Berman Date: Thu, 20 Sep 2018 15:50:03 +0200 Subject: [PATCH] Calculate total votes without making extra query. --- bigchaindb/elections/election.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bigchaindb/elections/election.py b/bigchaindb/elections/election.py index bcab8412..b6deff7c 100644 --- a/bigchaindb/elections/election.py +++ b/bigchaindb/elections/election.py @@ -207,8 +207,7 @@ class Election(Transaction): votes_committed = self.get_commited_votes(bigchain, election_pk) votes_current = self.count_votes(election_pk, current_votes) - current_validators = self.get_validators(bigchain) - total_votes = sum(current_validators.values()) + total_votes = sum(output.amount for output in self.outputs) if (votes_committed < (2/3) * total_votes) and \ (votes_committed + votes_current >= (2/3)*total_votes): return True