mirror of
https://github.com/alexgo-io/bitcoin-indexer.git
synced 2026-01-12 22:43:06 +08:00
fix: boot sequence
This commit is contained in:
@@ -106,7 +106,38 @@ impl Service {
|
||||
|
||||
let hord_config = self.config.get_hord_config();
|
||||
|
||||
if let Some((start_block, end_block)) = should_sync_hord_db(&self.config, &self.ctx)? {
|
||||
let (tx, rx) = channel();
|
||||
|
||||
let mut moved_event_observer_config = event_observer_config.clone();
|
||||
let moved_ctx = self.ctx.clone();
|
||||
|
||||
let _ = hiro_system_kit::thread_named("Initial predicate processing")
|
||||
.spawn(move || {
|
||||
if let Some(mut chainhook_config) =
|
||||
moved_event_observer_config.chainhook_config.take()
|
||||
{
|
||||
let mut bitcoin_predicates_ref: Vec<&BitcoinChainhookSpecification> = vec![];
|
||||
for bitcoin_predicate in chainhook_config.bitcoin_chainhooks.iter_mut() {
|
||||
bitcoin_predicate.enabled = false;
|
||||
bitcoin_predicates_ref.push(bitcoin_predicate);
|
||||
}
|
||||
while let Ok(block) = rx.recv() {
|
||||
let future = process_block_with_predicates(
|
||||
block,
|
||||
&bitcoin_predicates_ref,
|
||||
&moved_event_observer_config,
|
||||
&moved_ctx,
|
||||
);
|
||||
let res = hiro_system_kit::nestable_block_on(future);
|
||||
if let Err(_) = res {
|
||||
error!(moved_ctx.expect_logger(), "Initial ingestion failing");
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.expect("unable to spawn thread");
|
||||
|
||||
while let Some((start_block, end_block)) = should_sync_hord_db(&self.config, &self.ctx)? {
|
||||
if start_block == 0 {
|
||||
info!(
|
||||
self.ctx.expect_logger(),
|
||||
@@ -119,44 +150,12 @@ impl Service {
|
||||
);
|
||||
}
|
||||
|
||||
let (tx, rx) = channel();
|
||||
|
||||
let mut moved_event_observer_config = event_observer_config.clone();
|
||||
let moved_ctx = self.ctx.clone();
|
||||
|
||||
let _ = hiro_system_kit::thread_named("Initial predicate processing")
|
||||
.spawn(move || {
|
||||
if let Some(mut chainhook_config) =
|
||||
moved_event_observer_config.chainhook_config.take()
|
||||
{
|
||||
let mut bitcoin_predicates_ref: Vec<&BitcoinChainhookSpecification> =
|
||||
vec![];
|
||||
for bitcoin_predicate in chainhook_config.bitcoin_chainhooks.iter_mut() {
|
||||
bitcoin_predicate.enabled = false;
|
||||
bitcoin_predicates_ref.push(bitcoin_predicate);
|
||||
}
|
||||
while let Ok(block) = rx.recv() {
|
||||
let future = process_block_with_predicates(
|
||||
block,
|
||||
&bitcoin_predicates_ref,
|
||||
&moved_event_observer_config,
|
||||
&moved_ctx,
|
||||
);
|
||||
let res = hiro_system_kit::nestable_block_on(future);
|
||||
if let Err(_) = res {
|
||||
error!(moved_ctx.expect_logger(), "Initial ingestion failing");
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.expect("unable to spawn thread");
|
||||
|
||||
crate::hord::perform_hord_db_update(
|
||||
start_block,
|
||||
end_block,
|
||||
&self.config.get_hord_config(),
|
||||
&self.config,
|
||||
Some(tx),
|
||||
Some(tx.clone()),
|
||||
&self.ctx,
|
||||
)
|
||||
.await?;
|
||||
|
||||
Reference in New Issue
Block a user