Skip to content

Commit 239b26a

Browse files
author
Ludo Galabru
committed
fix: broken test
1 parent efc498b commit 239b26a

File tree

2 files changed

+51
-45
lines changed
  • components
    • chainhook-cli/src/cli
    • chainhook-event-observer/src/observer

2 files changed

+51
-45
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ async fn handle_command(opts: Opts, ctx: Context) -> Result<(), String> {
827827
cmd.end_block - cmd.start_block + 1
828828
);
829829
}
830-
DbCommand::Patch(cmd) => {
830+
DbCommand::Patch(_cmd) => {
831831
unimplemented!()
832832
}
833833
DbCommand::Migrate(cmd) => {

components/chainhook-event-observer/src/observer/mod.rs

+50-44
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use crate::hord::db::open_readwrite_hord_dbs;
1414
use crate::hord::new_traversals_lazy_cache;
1515
#[cfg(feature = "ordinals")]
1616
use crate::hord::{
17-
db::{open_readwrite_hord_db_conn, open_readwrite_hord_db_conn_rocks_db},
1817
revert_hord_db_with_augmented_bitcoin_block, update_hord_db_and_augment_bitcoin_block,
1918
};
2019
use crate::indexer::bitcoin::{
@@ -653,51 +652,9 @@ pub async fn start_observer_commands_handler(
653652
BlockchainEvent::BlockchainUpdatedWithHeaders(data) => {
654653
let mut new_blocks = vec![];
655654

656-
#[cfg(feature = "ordinals")]
657-
let (blocks_db, inscriptions_db_conn_rw) =
658-
match open_readwrite_hord_dbs(&config.get_cache_path_buf(), &ctx) {
659-
Ok(dbs) => dbs,
660-
Err(e) => {
661-
if let Some(ref tx) = observer_events_tx {
662-
let _ = tx.send(ObserverEvent::Error(format!(
663-
"Channel error: {:?}",
664-
e
665-
)));
666-
} else {
667-
ctx.try_log(|logger| {
668-
slog::error!(
669-
logger,
670-
"Unable to open readwtite connection",
671-
)
672-
});
673-
}
674-
continue;
675-
}
676-
};
677-
678655
for header in data.new_headers.iter() {
679-
match bitcoin_block_store.get_mut(&header.block_identifier) {
656+
match bitcoin_block_store.get(&header.block_identifier) {
680657
Some(block) => {
681-
#[cfg(feature = "ordinals")]
682-
{
683-
if let Err(e) = update_hord_db_and_augment_bitcoin_block(
684-
block,
685-
&blocks_db,
686-
&inscriptions_db_conn_rw,
687-
true,
688-
&config.get_cache_path_buf(),
689-
&traversals_cache,
690-
&ctx,
691-
) {
692-
ctx.try_log(|logger| {
693-
slog::error!(
694-
logger,
695-
"Unable to insert bitcoin block {} in hord_db: {e}",
696-
block.block_identifier.index
697-
)
698-
});
699-
}
700-
}
701658
new_blocks.push(block.clone());
702659
}
703660
None => {
@@ -712,6 +669,55 @@ pub async fn start_observer_commands_handler(
712669
}
713670
}
714671

672+
#[cfg(feature = "ordinals")]
673+
{
674+
if config.ordinals_enabled {
675+
let (blocks_db, inscriptions_db_conn_rw) =
676+
match open_readwrite_hord_dbs(
677+
&config.get_cache_path_buf(),
678+
&ctx,
679+
) {
680+
Ok(dbs) => dbs,
681+
Err(e) => {
682+
if let Some(ref tx) = observer_events_tx {
683+
let _ = tx.send(ObserverEvent::Error(format!(
684+
"Channel error: {:?}",
685+
e
686+
)));
687+
} else {
688+
ctx.try_log(|logger| {
689+
slog::error!(
690+
logger,
691+
"Unable to open readwtite connection",
692+
)
693+
});
694+
}
695+
continue;
696+
}
697+
};
698+
699+
for block in new_blocks.iter_mut() {
700+
if let Err(e) = update_hord_db_and_augment_bitcoin_block(
701+
block,
702+
&blocks_db,
703+
&inscriptions_db_conn_rw,
704+
true,
705+
&config.get_cache_path_buf(),
706+
&traversals_cache,
707+
&ctx,
708+
) {
709+
ctx.try_log(|logger| {
710+
slog::error!(
711+
logger,
712+
"Unable to insert bitcoin block {} in hord_db: {e}",
713+
block.block_identifier.index
714+
)
715+
});
716+
}
717+
}
718+
}
719+
};
720+
715721
for header in data.confirmed_headers.iter() {
716722
match bitcoin_block_store.remove(&header.block_identifier) {
717723
Some(block) => {

0 commit comments

Comments
 (0)