From 4f56ed43e1e06b6b98ec851988bd4a3971c67c61 Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 3 May 2016 16:08:10 +0200 Subject: [PATCH] comments on voting logic --- bigchaindb/core.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bigchaindb/core.py b/bigchaindb/core.py index 4c3575c5..9e01bce7 100644 --- a/bigchaindb/core.py +++ b/bigchaindb/core.py @@ -504,6 +504,11 @@ class Bigchain(object): n_valid_votes = sum(vote_list) n_invalid_votes = len(vote_list) - n_valid_votes + # The use of ceiling and floor is to account for the case of an + # even number of voters where half the voters have voted 'invalid' + # and half 'valid'. In this case, the block should marked invalid + # to avoid a hung election. In the case of an odd number of voters + # this is not relevant, since one side must be a majority. if n_invalid_votes >= math.ceil(n_voters / 2): return 'invalid' elif n_valid_votes > math.floor(n_voters / 2):