Skip to content

Commit

Permalink
add --indexer OPTION for reset-data subcommand.
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanYuan committed Dec 15, 2023
1 parent 2412cf7 commit 45e7c8e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ckb-bin/src/subcommand/reset_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ pub fn reset_data(args: ResetDataArgs) -> Result<(), ExitCode> {
target_dirs.push(args.db_path);
}

if args.indexer {
target_dirs.push(args.indexer_path);
}

if args.network {
target_dirs.push(args.network_dir);
}
Expand Down
1 change: 1 addition & 0 deletions resource/ckb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ block_uncles_cache_size = 30
# # Or you may want use more flexible scripts, block template as arg.
# notify_scripts = ["{cmd} {blocktemplate}"]
#
# # CKB built-in indexer settings. Existing indexes can be cleaned up using the `ckb reset-data` subcommand.
# [indexer_v2]
# # Indexing the pending txs in the ckb tx-pool
# index_tx_pool = false
Expand Down
4 changes: 4 additions & 0 deletions util/app-config/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ pub struct ResetDataArgs {
pub all: bool,
/// Reset database.
pub database: bool,
/// Reset indexer.
pub indexer: bool,
/// Reset all network data, including the secret key and peer store.
pub network: bool,
/// Reset network peer store.
Expand All @@ -158,6 +160,8 @@ pub struct ResetDataArgs {
pub data_dir: PathBuf,
/// The path to the database directory.
pub db_path: PathBuf,
/// The path to the indexer directory.
pub indexer_path: PathBuf,
/// The path to the network data directory.
pub network_dir: PathBuf,
/// The path to the network peer store directory.
Expand Down
6 changes: 6 additions & 0 deletions util/app-config/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,12 @@ fn reset_data() -> Command {
.action(clap::ArgAction::SetTrue)
.help("Delete only `data/db`"),
)
.arg(
Arg::new(ARG_INDEXER)
.long(ARG_INDEXER)
.action(clap::ArgAction::SetTrue)
.help("Delete only `data/indexer/store`"),
)
.arg(
Arg::new(ARG_NETWORK)
.long(ARG_NETWORK)
Expand Down
4 changes: 4 additions & 0 deletions util/app-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ impl Setup {
let config = self.config.into_ckb()?;
let data_dir = config.data_dir;
let db_path = config.db.path;
let indexer_path = config.indexer.store;
let network_config = config.network;
let network_dir = network_config.path.clone();
let network_peer_store_path = network_config.peer_store_path();
Expand All @@ -315,6 +316,7 @@ impl Setup {
let force = matches.get_flag(cli::ARG_FORCE);
let all = matches.get_flag(cli::ARG_ALL);
let database = matches.get_flag(cli::ARG_DATABASE);
let indexer = matches.get_flag(cli::ARG_INDEXER);
let network = matches.get_flag(cli::ARG_NETWORK);
let network_peer_store = matches.get_flag(cli::ARG_NETWORK_PEER_STORE);
let network_secret_key = matches.get_flag(cli::ARG_NETWORK_SECRET_KEY);
Expand All @@ -324,12 +326,14 @@ impl Setup {
force,
all,
database,
indexer,
network,
network_peer_store,
network_secret_key,
logs,
data_dir,
db_path,
indexer_path,
network_dir,
network_peer_store_path,
network_secret_key_path,
Expand Down

0 comments on commit 45e7c8e

Please sign in to comment.