feat: add --check-blocks-integrity flag

This commit is contained in:
Ludo Galabru
2024-01-04 22:19:12 -05:00
parent 424f5bb98c
commit d7d90e71bf
2 changed files with 10 additions and 2 deletions

View File

@@ -339,6 +339,9 @@ struct StartCommand {
/// HTTP Auth token
#[clap(long = "auth-token")]
pub auth_token: Option<String>,
/// Check blocks integrity
#[clap(long = "check-blocks-integrity")]
pub block_integrity_check: bool,
}
#[derive(Subcommand, PartialEq, Clone, Debug)]
@@ -740,7 +743,9 @@ async fn handle_command(opts: Opts, ctx: &Context) -> Result<(), String> {
}
let mut service = Service::new(config, ctx.clone());
return service.run(predicates, None).await;
return service
.run(predicates, None, cmd.block_integrity_check)
.await;
}
},
Command::Config(subcmd) => match subcmd {

View File

@@ -67,11 +67,14 @@ impl Service {
predicate_activity_relayer: Option<
crossbeam_channel::Sender<BitcoinChainhookOccurrencePayload>,
>,
check_blocks_integrity: bool,
) -> Result<(), String> {
let mut event_observer_config = self.config.get_event_observer_config();
// Catch-up with chain tip
let chain_tip_height = self.catch_up_with_chain_tip(false, false).await?;
let chain_tip_height = self
.catch_up_with_chain_tip(false, check_blocks_integrity)
.await?;
info!(
self.ctx.expect_logger(),
"Database up to date, service will start streaming blocks"