Adds cli interface to allow reseting chain to a particular block (#9782)

* added BlockChainReset trait, client impl, and cli interface

* show block hashes to be deleted and new best block, update best block in db, better cli interface

* delete BlockNumber from COL_EXTRA

* add TODO comment

* add BlockReciepts to imports

* refactor block_headers_from_best_block, better cli documentation

* exit gracefully if reset arg isn't supplied

* fix cli usage macro

* removed stray int literals

* use Vec::with_capacity

Co-Authored-By: seunlanlege <seunlanlege@gmail.com>

* cast n to usize

* correct imports

* make db reset arg required
This commit is contained in:
Seun LanLege
2019-01-16 19:37:26 +04:00
committed by Afri Schoedon
parent 1df6361753
commit cdba22a2cb
8 changed files with 137 additions and 6 deletions

View File

@@ -217,6 +217,15 @@ usage! {
CMD cmd_db_kill {
"Clean the database of the given --chain (default: mainnet)",
}
CMD cmd_db_reset {
"Removes NUM latests blocks from the db",
ARG arg_db_reset_num: (u32) = 10u32,
"<NUM>",
"Number of blocks to revert",
}
}
CMD cmd_export_hardcoded_sync
@@ -1612,6 +1621,7 @@ mod tests {
cmd_tools_hash: false,
cmd_db: false,
cmd_db_kill: false,
cmd_db_reset: false,
cmd_export_hardcoded_sync: false,
// Arguments
@@ -1631,6 +1641,7 @@ mod tests {
arg_dapp_path: None,
arg_account_import_path: None,
arg_wallet_import_path: None,
arg_db_reset_num: 10,
// -- Operating Options
arg_mode: "last".into(),