Browse Source

Fixed another issue causing ATStatesHeightIndex to go missing after pruning.

block-archive
CalDescent 3 years ago
parent
commit
841b6c4ddf
  1. 10
      src/main/java/org/qortal/repository/hsqldb/HSQLDBDatabasePruning.java

10
src/main/java/org/qortal/repository/hsqldb/HSQLDBDatabasePruning.java

@ -71,6 +71,11 @@ public class HSQLDBDatabasePruning {
repository.executeCheckedUpdate("SET TABLE ATStatesNew NEW SPACE");
repository.executeCheckedUpdate("CHECKPOINT");
// Add a height index
LOGGER.info("Adding index to AT states table...");
repository.executeCheckedUpdate("CREATE INDEX IF NOT EXISTS ATStatesNewHeightIndex ON ATStatesNew (height)");
repository.executeCheckedUpdate("CHECKPOINT");
// Find our latest block
BlockData latestBlock = repository.getBlockRepository().getLastBlock();
@ -149,15 +154,12 @@ public class HSQLDBDatabasePruning {
repository.saveChanges();
// Add a height index
LOGGER.info("Rebuilding AT states height index in repository");
repository.executeCheckedUpdate("CREATE INDEX IF NOT EXISTS ATStatesHeightIndex ON ATStatesNew (height)");
repository.executeCheckedUpdate("CHECKPOINT");
// Finally, drop the original table and rename
LOGGER.info("Deleting old AT states...");
repository.executeCheckedUpdate("DROP TABLE ATStates");
repository.executeCheckedUpdate("ALTER TABLE ATStatesNew RENAME TO ATStates");
repository.executeCheckedUpdate("ALTER INDEX ATStatesNewHeightIndex RENAME TO ATStatesHeightIndex");
repository.executeCheckedUpdate("CHECKPOINT");
// Update the prune height

Loading…
Cancel
Save