diff --git a/src/httpapi/miscpublicapi/getblocks.py b/src/httpapi/miscpublicapi/getblocks.py index d966fcc0..6e6773af 100755 --- a/src/httpapi/miscpublicapi/getblocks.py +++ b/src/httpapi/miscpublicapi/getblocks.py @@ -46,15 +46,16 @@ def get_public_block_list(public_API, request): return Response(share_list) -def get_block_data(public_API, data): - """data is the block hash in hex""" +def get_block_data(public_API, b_hash): + """return block data by hash unless we are hiding it""" resp = '' - if stringvalidators.validate_hash(data): + b_hash = reconstructhash.reconstruct_hash(b_hash) + if stringvalidators.validate_hash(b_hash): if not config.get('general.hide_created_blocks', True) \ - or data not in public_API.hideBlocks: - if data in public_API._too_many.get(BlockList).get(): - block = apiutils.GetBlockData().get_block_data( - data, raw=True, decrypt=False) + or b_hash not in public_API.hideBlocks: + if b_hash in public_API._too_many.get(BlockList).get(): + block = apiutils.GetBlockData().get_block_b_hash( + b_hash, raw=True, decrypt=False) try: # Encode in case data is binary block = block.encode('utf-8') @@ -67,4 +68,5 @@ def get_block_data(public_API, data): abort(404) resp = "" # Has to be octet stream, otherwise binary data fails hash check - return Response(resp, mimetype='application/octet-stream') \ No newline at end of file + return Response(resp, mimetype='application/octet-stream') + \ No newline at end of file