Skip to content

Commit fa6c86f

Browse files
author
Ludo Galabru
committed
feat: prototype warmup
1 parent 4683211 commit fa6c86f

File tree

4 files changed

+747
-44
lines changed

4 files changed

+747
-44
lines changed

components/hord-cli/src/cli/mod.rs

+37-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::archive::download_ordinals_dataset_if_required;
22
use crate::config::generator::generate_config;
33
use crate::config::Config;
4+
use crate::hord::ordinals::start_ordinals_number_processor;
45
use crate::scan::bitcoin::scan_bitcoin_chainstate_via_rpc_using_predicate;
56
use crate::service::Service;
67

@@ -155,15 +156,18 @@ struct ScanInscriptionCommand {
155156
#[derive(Subcommand, PartialEq, Clone, Debug)]
156157
enum RepairCommand {
157158
/// 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),
160164
/// Rewrite blocks hord db
161165
#[clap(name = "transfers", bin_name = "transfers")]
162166
Transfers(RepairTransfersCommand),
163167
}
164168

165169
#[derive(Parser, PartialEq, Clone, Debug)]
166-
struct RepairBlocksCommand {
170+
struct RepairStorageCommand {
167171
/// Starting block
168172
pub start_block: u64,
169173
/// Starting block
@@ -655,7 +659,7 @@ async fn handle_command(opts: Opts, ctx: &Context) -> Result<(), String> {
655659
&transaction_identifier,
656660
0,
657661
0,
658-
Arc::new(traversals_cache),
662+
&Arc::new(traversals_cache),
659663
&ctx,
660664
)?;
661665
info!(
@@ -721,12 +725,39 @@ async fn handle_command(opts: Opts, ctx: &Context) -> Result<(), String> {
721725
}
722726
}
723727
Command::Repair(subcmd) => match subcmd {
724-
RepairCommand::Blocks(cmd) => {
728+
RepairCommand::Rocksdb(cmd) => {
725729
let config = Config::default(false, false, false, &cmd.config_path)?;
726730
let mut hord_config = config.get_hord_config();
727731
hord_config.network_thread_max = cmd.network_threads;
728732

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();
730761
}
731762
RepairCommand::Transfers(cmd) => {
732763
let config = Config::default(false, false, false, &cmd.config_path)?;

0 commit comments

Comments
 (0)