adding pagination to namespace fetch all names endpoint, and changed validation error behavior to filter+log rather than return error response

This commit is contained in:
Aaron Blankstein
2017-04-18 15:51:10 -04:00
parent 5fd7b1587f
commit 2732647a65
2 changed files with 19 additions and 5 deletions

View File

@@ -743,8 +743,13 @@ def get_names_in_namespace_page(namespace_id, offset, count, proxy=None):
return resp
# must be valid names
valid_names = []
for n in resp['names']:
assert scripts.is_name_valid(str(n)), ('Invalid name {}'.format(str(n)))
if not scripts.is_name_valid(str(n)):
log.error('Invalid name "{}"'.format(str(n)))
else:
valid_names.append(n)
return valid_names
except (ValidationError, AssertionError) as e:
log.exception(e)
resp = json_traceback(resp.get('error'))
@@ -755,8 +760,6 @@ def get_names_in_namespace_page(namespace_id, offset, count, proxy=None):
resp = {'error': 'Failed to contact Blockstack node. Try again with `--debug`.'}
return resp
return resp['names']
def get_num_names_in_namespace(namespace_id, proxy=None):
"""