use of org.aion.zero.impl.AionBlockchainImpl in project aion by aionnetwork.
the class RecoveryUtils method pruneAndCorrect.
/**
* Used by the CLI call.
*/
public static void pruneAndCorrect() {
// ensure mining is disabled
CfgAion cfg = CfgAion.inst();
cfg.dbFromXML();
cfg.getConsensus().setMining(false);
cfg.getDb().setHeapCacheEnabled(false);
Map<String, String> cfgLog = new HashMap<>();
cfgLog.put("DB", "INFO");
cfgLog.put("GEN", "INFO");
AionLoggerFactory.init(cfgLog);
// get the current blockchain
AionBlockchainImpl blockchain = AionBlockchainImpl.inst();
IBlockStoreBase store = blockchain.getBlockStore();
IBlock bestBlock = store.getBestBlock();
if (bestBlock == null) {
System.out.println("Empty database. Nothing to do.");
return;
}
// revert to block number and flush changes
store.pruneAndCorrect();
store.flush();
// compact database after the changes were applied
blockchain.getRepository().compact();
blockchain.getRepository().close();
}
use of org.aion.zero.impl.AionBlockchainImpl in project aion by aionnetwork.
the class RecoveryUtils method revertTo.
/**
* Used by the CLI call.
*/
public static Status revertTo(long nbBlock) {
// ensure mining is disabled
CfgAion cfg = CfgAion.inst();
cfg.dbFromXML();
cfg.getConsensus().setMining(false);
Map<String, String> cfgLog = new HashMap<>();
cfgLog.put("DB", "INFO");
cfgLog.put("GEN", "INFO");
AionLoggerFactory.init(cfgLog);
// get the current blockchain
AionBlockchainImpl blockchain = AionBlockchainImpl.inst();
Status status = revertTo(blockchain, nbBlock);
blockchain.getRepository().close();
// ok if we managed to get down to the expected block
return status;
}
Aggregations