mirror of
https://github.com/planetmint/planetmint.git
synced 2025-11-24 22:45:44 +00:00
fixed pre_commiT-state bug
This commit is contained in:
parent
148a188f8f
commit
af34e25c1b
@ -367,8 +367,6 @@ def delete_transactions(connection, txn_ids: list):
|
||||
@register_query(TarantoolDB)
|
||||
def store_pre_commit_state(connection, state: dict):
|
||||
space = connection.space("pre_commits")
|
||||
if not space:
|
||||
return {}
|
||||
_precommit = space.select(state["height"], index="height_search", limit=1)
|
||||
unique_id = token_hex(8) if (len(_precommit.data) == 0) else _precommit.data[0][0]
|
||||
space.upsert((unique_id, state["height"], state["transactions"]),
|
||||
@ -380,15 +378,10 @@ def store_pre_commit_state(connection, state: dict):
|
||||
|
||||
@register_query(TarantoolDB)
|
||||
def get_pre_commit_state(connection):
|
||||
try:
|
||||
space = connection.space("pre_commits")
|
||||
_commit = space.select([], index="id_search", limit=1).data
|
||||
if len(_commit) == 0:
|
||||
return {}
|
||||
_commit = _commit[0]
|
||||
return {"height": _commit[1], "transactions": _commit[2]}
|
||||
except:
|
||||
return {}
|
||||
space = connection.space("pre_commits")
|
||||
_commit = space.select([], index="id_search").data
|
||||
_commit = sorted(_commit, key=itemgetter(1), reverse=True)[0]
|
||||
return {"height": _commit[1], "transactions": _commit[2]}
|
||||
|
||||
|
||||
@register_query(TarantoolDB)
|
||||
|
||||
@ -458,7 +458,6 @@ class Planetmint(object):
|
||||
return backend.query.get_election(self.connection, election_id)
|
||||
|
||||
def get_pre_commit_state(self):
|
||||
print(f"CONNECTION {self.connection} !!!!!")
|
||||
return backend.query.get_pre_commit_state(self.connection)
|
||||
|
||||
def store_pre_commit_state(self, state):
|
||||
|
||||
@ -465,7 +465,7 @@ def test_validator_update(db_conn):
|
||||
|
||||
for i in range(1, 100, 10):
|
||||
value = gen_validator_update(i)
|
||||
query.store_validator_set(connection=conn, validators_update=value)
|
||||
query.store_validator_set(conn=conn, validators_update=value)
|
||||
|
||||
v1 = query.get_validator_set(connection=conn, height=8)
|
||||
assert v1['height'] == 1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user