mirror of
https://github.com/planetmint/planetmint.git
synced 2025-11-25 06:55:45 +00:00
fixes for error NoneType
This commit is contained in:
parent
4d1815c4c4
commit
4819fccb59
@ -115,7 +115,8 @@ def get_metadata(connection, transaction_ids: list):
|
||||
metadata = connection.run(
|
||||
connection.space("meta_data").select(_id, index="id_search")
|
||||
)
|
||||
if metadata is not None or len(metadata) > 0:
|
||||
if metadata is not None:
|
||||
if len(metadata) > 0:
|
||||
_returned_data.append(metadata)
|
||||
return _returned_data if len(_returned_data) > 0 else None
|
||||
|
||||
@ -178,6 +179,7 @@ def get_latest_block(connection): # TODO Here is used DESCENDING OPERATOR
|
||||
)
|
||||
block = {"app_hash": '', "height": 0, "transactions": []}
|
||||
|
||||
if _all_blocks is not None:
|
||||
if len(_all_blocks) > 0:
|
||||
_block = sorted(_all_blocks, key=itemgetter(1), reverse=True)[0]
|
||||
_txids = connection.run(
|
||||
@ -475,13 +477,14 @@ def get_validator_set(connection, height: int = None):
|
||||
_validators = connection.run(
|
||||
connection.space("validators").select()
|
||||
)
|
||||
if height is not None:
|
||||
if height is not None and _validators is not None:
|
||||
_validators = [{"height": validator[1], "validators": validator[2]} for validator in _validators if
|
||||
validator[1] <= height]
|
||||
return next(iter(sorted(_validators, key=lambda k: k["height"], reverse=True)), None)
|
||||
else:
|
||||
elif _validators is not None:
|
||||
_validators = [{"height": validator[1], "validators": validator[2]} for validator in _validators]
|
||||
return next(iter(sorted(_validators, key=lambda k: k["height"], reverse=True)), None)
|
||||
return None
|
||||
|
||||
|
||||
@register_query(TarantoolDBConnection)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user