added committee vote function of first step of Reduction

parent 2e164077
......@@ -10,3 +10,5 @@ lambda_block = 30 #seconds
BLOCK_PROPOSAL_MSG_type = 'BLOCK_PROPOSAL_MSGs'
PRIORITY_MSG_type = 'PRIORITY_MSG'
COMMITTEE_VOTE_MSG_type = "COMMITTEE_VOTE"
......@@ -2,3 +2,7 @@
2 3
3 4
4 1
3 5
2 6
3 7
7 4
\ No newline at end of file
......@@ -2,3 +2,6 @@
2
3
4
5
6
7
\ No newline at end of file
......@@ -102,8 +102,6 @@ class OverlayNode(Node):
self.uniqueReceivedMessages.pop(Config.PRIORITY_MSG_type)
except Exception:
pass
# print("NOde id :"+self.id)
# print(self.uniqueReceivedMessages)
######### Performing selection of block BA* ############################
if not (self.uniqueReceivedMessages[Config.BLOCK_PROPOSAL_MSG_type] or blockForBA) :
......@@ -129,23 +127,35 @@ class OverlayNode(Node):
except Exception as e:
self.logger.error(e)
print(blockForBA)
# print(blockForBA)
hashof_blockForBA = Utility.pseudoRandomGenerator(blockForBA)
######### END : Performing selection of block BA* ############################
''' START : REDUCTION ALGORITHM '''
# reduct_step_1 = 1
# reduct_seed = (previousHash, self.currentRound, reduct_step_1)
# reduct_hash, reduct_proof, reduct_j = Utility.sortition(self.sk, reduct_seed, Config.tou_step, Config.ROLE_COMMITEE_FOR_VOTE,
# self.weight, self.network.badaW, self.pk)
#
# if reduct_j :
# self.logger.info("selection for VOTIN COMMITEE with J =" + str(reduct_j))
''' COmmitte vote reduction step 1'''
reduct_step_1 = 1
reduct_seed = (previousHash, self.currentRound, reduct_step_1)
reduct_role_1 = (Config.ROLE_COMMITEE_FOR_VOTE,self.currentRound,reduct_step_1)
reduct_sorthash, reduct_proof, reduct_j = Utility.sortition(self.sk, reduct_seed, Config.tou_step, reduct_role_1,
self.weight, self.network.badaW, self.pk)
print(self.id," : ",reduct_j)
if reduct_j > 0:
self.logger.info("selection for VOTING COMMITEE with J =" + str(reduct_j))
payload = (self.currentRound,reduct_step_1,reduct_sorthash,reduct_proof,previousHash,hashof_blockForBA)
committeeVoteMsg = (Config.COMMITTEE_VOTE_MSG_type,(self.pk,payload,self.sk.sign(bytes(str(payload).encode('UTF8')))))
self.broadcast(self.network.time,committeeVoteMsg)
self.logger.info("Broadcasting commitee messgae"+str(committeeVoteMsg))
print(self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type])
''' END : COmmitte vote reduction step 1'''
yield "resume", 9
self.logger.info(self.uniqueReceivedMessages)
# self.logger.info(self.uniqueReceivedMessages)
yield "resume",400
''' END : REDUCTION ALGORITHM '''
'''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment