|
1 | 1 | use crate::archive::download_ordinals_dataset_if_required;
|
2 | 2 | use crate::config::generator::generate_config;
|
3 | 3 | use crate::config::Config;
|
| 4 | +use crate::hord::ordinals::start_ordinals_number_processor; |
4 | 5 | use crate::scan::bitcoin::scan_bitcoin_chainstate_via_rpc_using_predicate;
|
5 | 6 | use crate::service::Service;
|
6 | 7 |
|
@@ -155,15 +156,18 @@ struct ScanInscriptionCommand {
|
155 | 156 | #[derive(Subcommand, PartialEq, Clone, Debug)]
|
156 | 157 | enum RepairCommand {
|
157 | 158 | /// Rewrite blocks hord db
|
158 |
| - #[clap(name = "blocks", bin_name = "blocks")] |
159 |
| - Blocks(RepairBlocksCommand), |
| 159 | + #[clap(name = "rocksdb", bin_name = "rocksdb")] |
| 160 | + Rocksdb(RepairStorageCommand), |
| 161 | + /// Rewrite blocks hord db |
| 162 | + #[clap(name = "sqlite", bin_name = "sqlite")] |
| 163 | + Sqlite(RepairStorageCommand), |
160 | 164 | /// Rewrite blocks hord db
|
161 | 165 | #[clap(name = "transfers", bin_name = "transfers")]
|
162 | 166 | Transfers(RepairTransfersCommand),
|
163 | 167 | }
|
164 | 168 |
|
165 | 169 | #[derive(Parser, PartialEq, Clone, Debug)]
|
166 |
| -struct RepairBlocksCommand { |
| 170 | +struct RepairStorageCommand { |
167 | 171 | /// Starting block
|
168 | 172 | pub start_block: u64,
|
169 | 173 | /// Starting block
|
@@ -655,7 +659,7 @@ async fn handle_command(opts: Opts, ctx: &Context) -> Result<(), String> {
|
655 | 659 | &transaction_identifier,
|
656 | 660 | 0,
|
657 | 661 | 0,
|
658 |
| - Arc::new(traversals_cache), |
| 662 | + &Arc::new(traversals_cache), |
659 | 663 | &ctx,
|
660 | 664 | )?;
|
661 | 665 | info!(
|
@@ -721,12 +725,39 @@ async fn handle_command(opts: Opts, ctx: &Context) -> Result<(), String> {
|
721 | 725 | }
|
722 | 726 | }
|
723 | 727 | Command::Repair(subcmd) => match subcmd {
|
724 |
| - RepairCommand::Blocks(cmd) => { |
| 728 | + RepairCommand::Rocksdb(cmd) => { |
725 | 729 | let config = Config::default(false, false, false, &cmd.config_path)?;
|
726 | 730 | let mut hord_config = config.get_hord_config();
|
727 | 731 | hord_config.network_thread_max = cmd.network_threads;
|
728 | 732 |
|
729 |
| - rebuild_rocks_db(&config, cmd.start_block, cmd.end_block, &ctx).await? |
| 733 | + rebuild_rocks_db( |
| 734 | + &config, |
| 735 | + cmd.start_block, |
| 736 | + cmd.end_block, |
| 737 | + hord_config.first_inscription_height, |
| 738 | + None, |
| 739 | + &ctx, |
| 740 | + ) |
| 741 | + .await? |
| 742 | + } |
| 743 | + RepairCommand::Sqlite(cmd) => { |
| 744 | + let config = Config::default(false, false, false, &cmd.config_path)?; |
| 745 | + let mut hord_config = config.get_hord_config(); |
| 746 | + hord_config.network_thread_max = cmd.network_threads; |
| 747 | + |
| 748 | + let (tx, handle) = start_ordinals_number_processor(&config, ctx); |
| 749 | + |
| 750 | + rebuild_rocks_db( |
| 751 | + &config, |
| 752 | + cmd.start_block, |
| 753 | + cmd.end_block, |
| 754 | + hord_config.first_inscription_height, |
| 755 | + Some(tx), |
| 756 | + &ctx, |
| 757 | + ) |
| 758 | + .await?; |
| 759 | + |
| 760 | + let _ = handle.join(); |
730 | 761 | }
|
731 | 762 | RepairCommand::Transfers(cmd) => {
|
732 | 763 | let config = Config::default(false, false, false, &cmd.config_path)?;
|
|
0 commit comments