allow truncated hashes in getblocks public endpoint
This commit is contained in:
parent
5abe4cf704
commit
092233027c
@ -46,15 +46,16 @@ def get_public_block_list(public_API, request):
|
|||||||
return Response(share_list)
|
return Response(share_list)
|
||||||
|
|
||||||
|
|
||||||
def get_block_data(public_API, data):
|
def get_block_data(public_API, b_hash):
|
||||||
"""data is the block hash in hex"""
|
"""return block data by hash unless we are hiding it"""
|
||||||
resp = ''
|
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) \
|
if not config.get('general.hide_created_blocks', True) \
|
||||||
or data not in public_API.hideBlocks:
|
or b_hash not in public_API.hideBlocks:
|
||||||
if data in public_API._too_many.get(BlockList).get():
|
if b_hash in public_API._too_many.get(BlockList).get():
|
||||||
block = apiutils.GetBlockData().get_block_data(
|
block = apiutils.GetBlockData().get_block_b_hash(
|
||||||
data, raw=True, decrypt=False)
|
b_hash, raw=True, decrypt=False)
|
||||||
try:
|
try:
|
||||||
# Encode in case data is binary
|
# Encode in case data is binary
|
||||||
block = block.encode('utf-8')
|
block = block.encode('utf-8')
|
||||||
@ -67,4 +68,5 @@ def get_block_data(public_API, data):
|
|||||||
abort(404)
|
abort(404)
|
||||||
resp = ""
|
resp = ""
|
||||||
# Has to be octet stream, otherwise binary data fails hash check
|
# Has to be octet stream, otherwise binary data fails hash check
|
||||||
return Response(resp, mimetype='application/octet-stream')
|
return Response(resp, mimetype='application/octet-stream')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user