added proper corner case handling in case a requested block is not found

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
This commit is contained in:
Jürgen Eckel 2023-01-10 18:21:48 +01:00
parent 34c4da2184
commit b3d6b07c93
No known key found for this signature in database

View File

@ -306,6 +306,8 @@ def get_spending_transactions(connection, inputs):
@register_query(TarantoolDBConnection)
def get_block(connection, block_id=None):
_block = connection.run(connection.space("blocks").select(block_id, index="height", limit=1))
if len(_block) == 0:
return
_block = Block.from_tuple(_block[0])
return _block.to_dict()