def __init__(self, host, port, phases, processing_node=None, max_inbound_connections=50, max_outbound_connections=50): # TODO consider to change phases back to array of ints and translate w/in the DB interface net_dao.reset_data() # TEMP FOR TESTING self.this_node = message_types.Node() self.host = host self.port = port self.business = None self.deploy_location = None self.vr_db_limit = None self.txn_db_limit = None # phase_type => {nodes} (dictionary of connected nodes) self.peer_dict = {} self.config = None # set of connected nodes self.connections = set() self.phases = int(phases) self.processing_node = processing_node # defaults to 15 minutes (900 seconds) self.receipt_request_time = 900 """ Load configured nodelist """ logger().info('loading network config...') self.load_config() logger().info('scheduling network tasks...') self.schedule_tasks() self.max_inbound_connections = max_inbound_connections self.max_outbound_connections = max_outbound_connections # BLOCKING logger().info('Starting RMI service handler...') # if testing network only without processing if processing_node is None: self.start_service_handler()
def __init__(self, host, port, phases, processing_node=None, max_inbound_connections=50, max_outbound_connections=50): # TODO consider to change phases back to array of ints and translate w/in the DB interface net_dao.reset_data() # TEMP FOR TESTING self.this_node = message_types.Node() self.host = host self.port = port self.business = None self.deploy_location = None # phase_type => {nodes} (dictionary of connected nodes) self.peer_dict = {} self.config = None # list of connected nodes self.connections = set() self.phases = int(phases) self.processing_node = processing_node """ Load configured nodelist """ logger().info('loading network config...') self.load_config() logger().info('scheduling network tasks...') self.schedule_tasks() self.max_inbound_connections = max_inbound_connections self.max_outbound_connections = max_outbound_connections # BLOCKING logger().info('Starting RMI service handler...') if processing_node is None: self.start_service_handler()
# format verifications to list of thrift structs for returning thrift_verifications = map(thrift_converter.get_verification_type, verifications) return thrift_verifications def receipt_request(self, pass_phrase): """ return unsent transfer ids to calling node """ if pass_phrase: self.authorize_pass_phrase(pass_phrase) transfer_node = self.registered_nodes[pass_phrase] return self.get_unsent_transfer_ids(transfer_node.node_id) def get_unsent_transfer_ids(self, transfer_to): """ retrieve unsent transfer record info (data used for querying block_verification database) """ unsent_transfer_ids = [] try: logger().info("Retrieving unsent transfer ids...") for transfer_record in vr_transfers_db.get_unsent_verification_records( transfer_to): unsent_transfer_ids.append(transfer_record['verification_id']) except: logger().warning("An SQL error has occurred.") return unsent_transfer_ids if __name__ == '__main__': net_dao.reset_data() connect1 = ConnectionManager('localhost', sys.argv[1], sys.argv[3])
subscription_messages = list(sub_vr_transfers_db.get_all(subscriber_info['subscriber_id'])) for message in subscription_messages: transactions += map(thrift_converter.convert_to_thrift_transaction, message['transactions']) verification_records += map(thrift_converter.get_verification_type, message['verifications']) # convert to thrift friendly response subscription_response = message_types.SubscriptionResponse() subscription_response.transactions = transactions subscription_response.verification_records = verification_records return subscription_response except Exception as ex: template = "An exception of type {0} occurred. Arguments:\n{1!r}" message = template.format(type(ex).__name__, ex.args) logger().warning(message) def get_unsent_transfer_ids(self, transfer_to): """ retrieve unsent transfer record info (data used for querying block_verification database) """ unsent_transfer_ids = [] try: logger().info("Retrieving unsent transfer ids...") for transfer_record in vr_transfers_db.get_unsent_verification_records(transfer_to): unsent_transfer_ids.append(transfer_record['verification_id']) except: logger().warning("An SQL error has occurred.") return unsent_transfer_ids if __name__ == '__main__': net_dao.reset_data() connect1 = ConnectionManager('localhost', sys.argv[1], sys.argv[3])