def blind_voting(merkle_root): vote_number = (int(merkle_root, 16) % nodeproperty.Total_peer_num) + 1 voting = {'To': vote_number, 'from': nodeproperty.My_IP_address, 'type': 'V'} jsonString = json.dumps(voting) if nodeproperty.My_peer_num == vote_number: file_controller.add_voting(jsonString) else: index = vote_number - 1 ip_address = peerproperty.nodeproperty.ConnectedPeerList[index][1] sender.send(ip_address, jsonString, nodeproperty.My_receiver_port)
def receive_event(p_thrd_name, p_inq, p_socketq): while True: logging.debug("Waiting for V type msg") recv_data = p_inq.get() request_sock = p_socketq.get() file_controller.add_voting(recv_data) difficulty = voting.result_voting() if (difficulty > 0): print("Enter block generator") block_generator.generate_block(difficulty, transaction.Merkle_root, transaction.Transactions) else: print("") request_sock.close()
def receive_event(p_thrd_name, p_inq): while True: monitoring.log("log.Waiting for V type msg") (recv_data, request_sock) = p_inq.get() # recv_data = p_inq.get() # request_sock = p_socketq.get() monitoring.log("log.V type msg rcvd: " + recv_data) file_controller.add_voting(recv_data) difficulty = voting.result_voting() if (difficulty > 0): monitoring.log("Enter block generator") block_generator.generate_block(difficulty, transaction.Merkle_root, transaction.Transactions) else: monitoring.log("log.") request_sock.close()