Skip to content

Commit bdccbb3

Browse files
committed
add --indexer OPTION for reset-data subcommand.
1 parent 2412cf7 commit bdccbb3

File tree

5 files changed

+19
-0
lines changed

5 files changed

+19
-0
lines changed

ckb-bin/src/subcommand/reset_data.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ pub fn reset_data(args: ResetDataArgs) -> Result<(), ExitCode> {
1616
target_dirs.push(args.db_path);
1717
}
1818

19+
if args.indexer {
20+
target_dirs.push(args.indexer_path);
21+
}
22+
1923
if args.network {
2024
target_dirs.push(args.network_dir);
2125
}

resource/ckb.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ block_uncles_cache_size = 30
196196
# # Or you may want use more flexible scripts, block template as arg.
197197
# notify_scripts = ["{cmd} {blocktemplate}"]
198198
#
199+
# # CKB built-in indexer settings. Existing indexes can be cleaned up using the `ckb reset-data` subcommand.
199200
# [indexer_v2]
200201
# # Indexing the pending txs in the ckb tx-pool
201202
# index_tx_pool = false

util/app-config/src/args.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ pub struct ResetDataArgs {
146146
pub all: bool,
147147
/// Reset database.
148148
pub database: bool,
149+
/// Reset indexer.
150+
pub indexer: bool,
149151
/// Reset all network data, including the secret key and peer store.
150152
pub network: bool,
151153
/// Reset network peer store.
@@ -158,6 +160,8 @@ pub struct ResetDataArgs {
158160
pub data_dir: PathBuf,
159161
/// The path to the database directory.
160162
pub db_path: PathBuf,
163+
/// The path to the indexer directory.
164+
pub indexer_path: PathBuf,
161165
/// The path to the network data directory.
162166
pub network_dir: PathBuf,
163167
/// The path to the network peer store directory.

util/app-config/src/cli.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,12 @@ fn reset_data() -> Command {
242242
.action(clap::ArgAction::SetTrue)
243243
.help("Delete only `data/db`"),
244244
)
245+
.arg(
246+
Arg::new(ARG_INDEXER)
247+
.long(ARG_INDEXER)
248+
.action(clap::ArgAction::SetTrue)
249+
.help("Delete only `data/indexer/store`"),
250+
)
245251
.arg(
246252
Arg::new(ARG_NETWORK)
247253
.long(ARG_NETWORK)

util/app-config/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ impl Setup {
306306
let config = self.config.into_ckb()?;
307307
let data_dir = config.data_dir;
308308
let db_path = config.db.path;
309+
let indexer_path = config.indexer.store;
309310
let network_config = config.network;
310311
let network_dir = network_config.path.clone();
311312
let network_peer_store_path = network_config.peer_store_path();
@@ -315,6 +316,7 @@ impl Setup {
315316
let force = matches.get_flag(cli::ARG_FORCE);
316317
let all = matches.get_flag(cli::ARG_ALL);
317318
let database = matches.get_flag(cli::ARG_DATABASE);
319+
let indexer = matches.get_flag(cli::ARG_INDEXER);
318320
let network = matches.get_flag(cli::ARG_NETWORK);
319321
let network_peer_store = matches.get_flag(cli::ARG_NETWORK_PEER_STORE);
320322
let network_secret_key = matches.get_flag(cli::ARG_NETWORK_SECRET_KEY);
@@ -324,12 +326,14 @@ impl Setup {
324326
force,
325327
all,
326328
database,
329+
indexer,
327330
network,
328331
network_peer_store,
329332
network_secret_key,
330333
logs,
331334
data_dir,
332335
db_path,
336+
indexer_path,
333337
network_dir,
334338
network_peer_store_path,
335339
network_secret_key_path,

0 commit comments

Comments
 (0)