mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
move quorum check to core
This commit is contained in:
@@ -475,3 +475,18 @@ class Bigchain(object):
|
||||
unvoted.pop(0)
|
||||
|
||||
return unvoted
|
||||
|
||||
def block_voted_invalid(self, block):
|
||||
"""
|
||||
Checks if block has enough invalid votes to make a decision
|
||||
"""
|
||||
n_voters = len(block['block']['voters'])
|
||||
|
||||
vote_list = [vote['vote']['is_block_valid'] for vote in block['votes']]
|
||||
|
||||
n_invalid_votes = vote_list.count(False)
|
||||
|
||||
if n_invalid_votes >= int(n_voters/2):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
@@ -208,15 +208,12 @@ class Election(object):
|
||||
"""
|
||||
Checks if block has enough invalid votes to make a decision
|
||||
"""
|
||||
b = Bigchain()
|
||||
|
||||
while True:
|
||||
next_block = self.q_block_new_vote.get()
|
||||
n_voters = len(next_block['block']['voters'])
|
||||
|
||||
vote_list = [vote['vote']['is_block_valid'] for vote in next_block['votes']]
|
||||
|
||||
n_invalid_votes = vote_list.count(False)
|
||||
|
||||
if n_invalid_votes >= int(n_voters/2):
|
||||
if b.block_voted_invalid(next_block):
|
||||
self.q_invalid_blocks.put(next_block)
|
||||
|
||||
def requeue_transactions(self):
|
||||
|
||||
Reference in New Issue
Block a user