diff --git a/planetmint/lib.py b/planetmint/lib.py index e7805da..f44fdcf 100644 --- a/planetmint/lib.py +++ b/planetmint/lib.py @@ -947,6 +947,11 @@ class Planetmint(object): elections = self._get_votes(txns) for election_id in elections: election = self.get_transaction(election_id) - election.on_rollback(self, new_height) + # election.on_rollback(self, new_height) + if election.operation == VALIDATOR_ELECTION: + # TODO change to `new_height + 2` when upgrading to Tendermint 0.24.0. + self.delete_validator_set(new_height + 1) + if election.operation == CHAIN_MIGRATION_ELECTION: + self.delete_abci_chain(new_height) Block = namedtuple("Block", ("app_hash", "height", "transactions")) diff --git a/planetmint/transactions/types/elections/chain_migration_election.py b/planetmint/transactions/types/elections/chain_migration_election.py index 8c2bbf1..58257d3 100644 --- a/planetmint/transactions/types/elections/chain_migration_election.py +++ b/planetmint/transactions/types/elections/chain_migration_election.py @@ -17,6 +17,3 @@ class ChainMigrationElection(Election): def on_approval(self, planet, *args, **kwargs): # TODO: move somewhere else planet.migrate_abci_chain() - - def on_rollback(self, planet, new_height): # TODO: move somewhere else - planet.delete_abci_chain(new_height) diff --git a/planetmint/transactions/types/elections/election.py b/planetmint/transactions/types/elections/election.py index b72031a..c4773c8 100644 --- a/planetmint/transactions/types/elections/election.py +++ b/planetmint/transactions/types/elections/election.py @@ -73,9 +73,3 @@ class Election(Transaction): other concluded elections, if required. """ raise NotImplementedError - - def on_rollback(self, planet, new_height): - """Override to clean up the database artifacts possibly created - in `on_approval`. Part of the `end_block`/`commit` crash recovery. - """ - raise NotImplementedError diff --git a/planetmint/transactions/types/elections/validator_election.py b/planetmint/transactions/types/elections/validator_election.py index 6d3bf14..670060c 100644 --- a/planetmint/transactions/types/elections/validator_election.py +++ b/planetmint/transactions/types/elections/validator_election.py @@ -31,7 +31,3 @@ class ValidatorElection(Election): # TODO change to `new_height + 2` when upgrading to Tendermint 0.24.0. planet.store_validator_set(new_height + 1, updated_validator_set) return encode_validator(self.asset["data"]) - - def on_rollback(self, planetmint, new_height): # TODO: move somewhere else - # TODO change to `new_height + 2` when upgrading to Tendermint 0.24.0. - planetmint.delete_validator_set(new_height + 1)