def get_p1_message(self, block_info): """ returns thrift phase 1 message structure """ verification_record = block_info['verification_record'] transactions = map(convert_to_thrift_transaction, verification_record['verification_info']) verification_record = convert_to_thrift_record(verification_record) phase_1_msg = message_types.Phase_1_msg() phase_1_msg.record = verification_record phase_1_msg.transactions = transactions return phase_1_msg
def get_p3_message(self, block_info): """returns thrift phase 3 message structure """ verification_record = block_info['verification_record'] verification_info = verification_record['verification_info'] phase_3_msg = message_types.Phase_3_msg() phase_3_msg.record = convert_to_thrift_record(verification_record) phase_3_msg.p2_count = verification_info['p2_count'] phase_3_msg.businesses = verification_info['businesses'] phase_3_msg.deploy_locations = verification_info['deploy_locations'] phase_3_msg.lower_hashes = verification_info['lower_hashes'] return phase_3_msg
def get_p2_message(self, block_info): """returns thrift phase 2 message structure """ verification_record = block_info['verification_record'] verification_info = verification_record['verification_info'] phase_2_msg = message_types.Phase_2_msg() phase_2_msg.record = convert_to_thrift_record(verification_record) phase_2_msg.valid_txs = map(convert_to_thrift_transaction, verification_info['valid_txs']) phase_2_msg.invalid_txs = map(convert_to_thrift_transaction, verification_info['invalid_txs']) phase_2_msg.business = verification_info['business'] phase_2_msg.deploy_location = verification_info['deploy_location'] return phase_2_msg
def phase_4_broadcast(self, block_info, phase_type): """ send phase_4 information for phase_5 execution """ ver_ids = [] verification_record = block_info['verification_record'] verification_info = verification_record['verification_info'] phase_4_msg = message_types.Phase_4_msg() phase_4_msg.record = thrift_converter.convert_to_thrift_record(verification_record) phase_4_msg.lower_hash = verification_info for node in self.peer_dict[phase_type]: try: ver_ids += node.client.phase_4_message(phase_4_msg) vrs = self.get_vrs(node, ver_ids) self.resolve_data(vrs, 4) except: logger().warning('failed to submit to node %s', node.node_id) continue