diff --git a/planetmint/backend/tarantool/query.py b/planetmint/backend/tarantool/query.py index d866afb..3773a19 100644 --- a/planetmint/backend/tarantool/query.py +++ b/planetmint/backend/tarantool/query.py @@ -8,6 +8,8 @@ from secrets import token_hex from operator import itemgetter +import tarantool.error + from planetmint.backend import query from planetmint.backend.utils import module_dispatch_registrar from planetmint.backend.tarantool.connection import TarantoolDB @@ -377,12 +379,17 @@ def store_pre_commit_state(connection, state: dict): @register_query(TarantoolDB) def get_pre_commit_state(connection): - space = connection.space("pre_commits") - _commit = space.select([], index="id_search").data - if len(_commit) == 0: + try: + space = connection.space("pre_commits") + _commit = space.select([], index="id_search").data + if len(_commit) == 0: + return None + _commit = sorted(_commit, key=itemgetter(1), reverse=True)[0] + return {"height": _commit[1], "transactions": _commit[2]} + except tarantool.error.SchemaError: return None - _commit = sorted(_commit, key=itemgetter(1), reverse=True)[0] - return {"height": _commit[1], "transactions": _commit[2]} + except Exception as err: + raise err @register_query(TarantoolDB) diff --git a/planetmint/backend/tarantool/schema.py b/planetmint/backend/tarantool/schema.py index 070f8c5..224c67b 100644 --- a/planetmint/backend/tarantool/schema.py +++ b/planetmint/backend/tarantool/schema.py @@ -9,7 +9,7 @@ register_schema = module_dispatch_registrar(backend.schema) SPACE_NAMES = ("abci_chains", "assets", "blocks", "blocks_tx", "elections", "meta_data", "pre_commits", "validators", - "transactions", "inputs", "outputs", "keys") + "transactions", "inputs", "outputs", "keys", "utxos") SPACE_COMMANDS = { "abci_chains": "abci_chains = box.schema.space.create('abci_chains', {engine='memtx', is_sync = false})", diff --git a/planetmint/lib.py b/planetmint/lib.py index 1297e94..0de282a 100644 --- a/planetmint/lib.py +++ b/planetmint/lib.py @@ -513,4 +513,5 @@ class Planetmint(object): return backend.query.delete_elections(self.connection, height) + Block = namedtuple('Block', ('app_hash', 'height', 'transactions')) diff --git a/requirements_old.txt b/requirements_old.txt deleted file mode 100644 index 4b26d68..0000000 --- a/requirements_old.txt +++ /dev/null @@ -1,64 +0,0 @@ -aiohttp==3.6.2 -aniso8601==9.0.1 -asn1crypto==1.4.0 -async-timeout==3.0.1 -attrs==21.4.0 -base58==1.0.3 -BigchainDB==2.2.2 -bigchaindb-abci==1.0.5 -capturer==3.0 -certifi==2021.10.8 -cffi==1.15.0 -chardet==3.0.4 -charset-normalizer==2.0.12 -click==8.0.3 -colorlog==4.1.0 -cryptoconditions==0.8.0 -cryptography==36.0.1 -Flask==1.1.2 -Flask-Cors==3.0.8 -Flask-RESTful==0.3.8 -gevent==20.6.2 -greenlet==0.4.16 -gunicorn==20.0.4 -humanfriendly==10.0 -hypothesis==6.39.3 -idna==2.10 -iniconfig==1.1.1 -itsdangerous==2.0.1 -Jinja2==3.0.3 -jsonschema==3.2.0 -logstats==0.3.0 -MarkupSafe==2.0.1 -msgpack==1.0.3 -multidict==4.7.6 -packaging==21.3 -Planetmint==0.9.0 -planetmint-cryptoconditions==0.9.3 -pluggy==1.0.0 -protobuf==3.6.1 -py==1.11.0 -pyasn1==0.4.8 -pycparser==2.21 -pymongo==3.7.2 -PyNaCl==1.1.2 -pyOpenSSL==22.0.0 -pyparsing==3.0.7 -pyrsistent==0.18.1 -pytest==7.0.1 -python-rapidjson==0.9.1 -pytz==2021.3 -PyYAML==5.3.1 -requests==2.23.0 -setproctitle==1.1.10 -six==1.16.0 -sortedcontainers==2.4.0 -tarantool==0.7.1 -tomli==2.0.1 -typing_extensions==4.1.1 -urllib3==1.25.11 -Werkzeug==2.0.3 -yarl==1.7.2 -zenroom==2.1.0.dev1647359536 -zope.event==4.5.0 -zope.interface==5.5.0.dev0 diff --git a/tests/commands/test_commands.py b/tests/commands/test_commands.py index 73c7dd3..a269c5d 100644 --- a/tests/commands/test_commands.py +++ b/tests/commands/test_commands.py @@ -20,7 +20,6 @@ from planetmint.migrations.chain_migration_election import ChainMigrationElectio from tests.utils import generate_election, generate_validators - def test_make_sure_we_dont_remove_any_command(): # thanks to: http://stackoverflow.com/a/18161115/597097 from planetmint.commands.planetmint import create_parser