From aec854dda9ecc2f8f9143a38dab30523b2d19140 Mon Sep 17 00:00:00 2001 From: EthanYuan Date: Fri, 15 Dec 2023 16:03:41 +0800 Subject: [PATCH] add --indexer OPTION for reset-data subcommand. --- ckb-bin/src/subcommand/reset_data.rs | 4 ++++ resource/ckb.toml | 1 + util/app-config/src/args.rs | 4 ++++ util/app-config/src/cli.rs | 6 ++++++ util/app-config/src/lib.rs | 4 ++++ 5 files changed, 19 insertions(+) diff --git a/ckb-bin/src/subcommand/reset_data.rs b/ckb-bin/src/subcommand/reset_data.rs index ee09812fb8c..f1952e84f5d 100644 --- a/ckb-bin/src/subcommand/reset_data.rs +++ b/ckb-bin/src/subcommand/reset_data.rs @@ -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); } diff --git a/resource/ckb.toml b/resource/ckb.toml index 3e32e68b750..74b94033af0 100644 --- a/resource/ckb.toml +++ b/resource/ckb.toml @@ -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 diff --git a/util/app-config/src/args.rs b/util/app-config/src/args.rs index 15c32640344..7072c72d893 100644 --- a/util/app-config/src/args.rs +++ b/util/app-config/src/args.rs @@ -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. @@ -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. diff --git a/util/app-config/src/cli.rs b/util/app-config/src/cli.rs index 06bc6470762..5dddf7316d8 100644 --- a/util/app-config/src/cli.rs +++ b/util/app-config/src/cli.rs @@ -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) diff --git a/util/app-config/src/lib.rs b/util/app-config/src/lib.rs index a8fbbab64da..fda0bafb81c 100644 --- a/util/app-config/src/lib.rs +++ b/util/app-config/src/lib.rs @@ -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(); @@ -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); @@ -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,