def create_banks(*, known_nodes, results): """ For each unknown bank, attempt to: - fetch config data - create new Bank object """ for bank in get_unknown_nodes(known_nodes=known_nodes, results=results): try: address = format_address(ip_address=bank.get('ip_address'), port=bank.get('port'), protocol=bank.get('protocol')) config_address = f'{address}/config' config_data = fetch(url=config_address, headers={}) serializer = BankConfigurationSerializer(data=config_data) if serializer.is_valid(): create_bank_from_config_data(config_data=config_data) continue logger.exception(serializer.errors) except Exception as e: capture_exception(e) logger.exception(e)
def create(self, validated_data): """Process validated connection request""" if validated_data['node_type'] == BANK: create_bank_from_config_data(config_data=validated_data) if validated_data['node_type'] == CONFIRMATION_VALIDATOR: create_validator_from_config_data(config_data=validated_data) return True