added committee vote function of first step of Reduction

parent 2e164077
...@@ -9,4 +9,6 @@ lambda_block = 30 #seconds ...@@ -9,4 +9,6 @@ lambda_block = 30 #seconds
BLOCK_PROPOSAL_MSG_type = 'BLOCK_PROPOSAL_MSGs' BLOCK_PROPOSAL_MSG_type = 'BLOCK_PROPOSAL_MSGs'
PRIORITY_MSG_type = 'PRIORITY_MSG' PRIORITY_MSG_type = 'PRIORITY_MSG'
\ No newline at end of file COMMITTEE_VOTE_MSG_type = "COMMITTEE_VOTE"
...@@ -2,3 +2,7 @@ ...@@ -2,3 +2,7 @@
2 3 2 3
3 4 3 4
4 1 4 1
3 5
2 6
3 7
7 4
\ No newline at end of file
...@@ -2,3 +2,6 @@ ...@@ -2,3 +2,6 @@
2 2
3 3
4 4
5
6
7
\ No newline at end of file
...@@ -102,8 +102,6 @@ class OverlayNode(Node): ...@@ -102,8 +102,6 @@ class OverlayNode(Node):
self.uniqueReceivedMessages.pop(Config.PRIORITY_MSG_type) self.uniqueReceivedMessages.pop(Config.PRIORITY_MSG_type)
except Exception: except Exception:
pass pass
# print("NOde id :"+self.id)
# print(self.uniqueReceivedMessages)
######### Performing selection of block BA* ############################ ######### Performing selection of block BA* ############################
if not (self.uniqueReceivedMessages[Config.BLOCK_PROPOSAL_MSG_type] or blockForBA) : if not (self.uniqueReceivedMessages[Config.BLOCK_PROPOSAL_MSG_type] or blockForBA) :
...@@ -129,23 +127,35 @@ class OverlayNode(Node): ...@@ -129,23 +127,35 @@ class OverlayNode(Node):
except Exception as e: except Exception as e:
self.logger.error(e) self.logger.error(e)
print(blockForBA) # print(blockForBA)
hashof_blockForBA = Utility.pseudoRandomGenerator(blockForBA)
######### END : Performing selection of block BA* ############################ ######### END : Performing selection of block BA* ############################
''' START : REDUCTION ALGORITHM ''' ''' 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 yield "resume", 9
self.logger.info(self.uniqueReceivedMessages) # self.logger.info(self.uniqueReceivedMessages)
yield "resume",400 yield "resume",400
''' END : REDUCTION ALGORITHM ''' ''' 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