mirror of
https://github.com/alexgo-io/bitcoin-indexer.git
synced 2026-01-12 22:43:06 +08:00
fix: broken test
This commit is contained in:
@@ -827,7 +827,7 @@ async fn handle_command(opts: Opts, ctx: Context) -> Result<(), String> {
|
||||
cmd.end_block - cmd.start_block + 1
|
||||
);
|
||||
}
|
||||
DbCommand::Patch(cmd) => {
|
||||
DbCommand::Patch(_cmd) => {
|
||||
unimplemented!()
|
||||
}
|
||||
DbCommand::Migrate(cmd) => {
|
||||
|
||||
@@ -14,7 +14,6 @@ use crate::hord::db::open_readwrite_hord_dbs;
|
||||
use crate::hord::new_traversals_lazy_cache;
|
||||
#[cfg(feature = "ordinals")]
|
||||
use crate::hord::{
|
||||
db::{open_readwrite_hord_db_conn, open_readwrite_hord_db_conn_rocks_db},
|
||||
revert_hord_db_with_augmented_bitcoin_block, update_hord_db_and_augment_bitcoin_block,
|
||||
};
|
||||
use crate::indexer::bitcoin::{
|
||||
@@ -653,51 +652,9 @@ pub async fn start_observer_commands_handler(
|
||||
BlockchainEvent::BlockchainUpdatedWithHeaders(data) => {
|
||||
let mut new_blocks = vec![];
|
||||
|
||||
#[cfg(feature = "ordinals")]
|
||||
let (blocks_db, inscriptions_db_conn_rw) =
|
||||
match open_readwrite_hord_dbs(&config.get_cache_path_buf(), &ctx) {
|
||||
Ok(dbs) => dbs,
|
||||
Err(e) => {
|
||||
if let Some(ref tx) = observer_events_tx {
|
||||
let _ = tx.send(ObserverEvent::Error(format!(
|
||||
"Channel error: {:?}",
|
||||
e
|
||||
)));
|
||||
} else {
|
||||
ctx.try_log(|logger| {
|
||||
slog::error!(
|
||||
logger,
|
||||
"Unable to open readwtite connection",
|
||||
)
|
||||
});
|
||||
}
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
for header in data.new_headers.iter() {
|
||||
match bitcoin_block_store.get_mut(&header.block_identifier) {
|
||||
match bitcoin_block_store.get(&header.block_identifier) {
|
||||
Some(block) => {
|
||||
#[cfg(feature = "ordinals")]
|
||||
{
|
||||
if let Err(e) = update_hord_db_and_augment_bitcoin_block(
|
||||
block,
|
||||
&blocks_db,
|
||||
&inscriptions_db_conn_rw,
|
||||
true,
|
||||
&config.get_cache_path_buf(),
|
||||
&traversals_cache,
|
||||
&ctx,
|
||||
) {
|
||||
ctx.try_log(|logger| {
|
||||
slog::error!(
|
||||
logger,
|
||||
"Unable to insert bitcoin block {} in hord_db: {e}",
|
||||
block.block_identifier.index
|
||||
)
|
||||
});
|
||||
}
|
||||
}
|
||||
new_blocks.push(block.clone());
|
||||
}
|
||||
None => {
|
||||
@@ -712,6 +669,55 @@ pub async fn start_observer_commands_handler(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "ordinals")]
|
||||
{
|
||||
if config.ordinals_enabled {
|
||||
let (blocks_db, inscriptions_db_conn_rw) =
|
||||
match open_readwrite_hord_dbs(
|
||||
&config.get_cache_path_buf(),
|
||||
&ctx,
|
||||
) {
|
||||
Ok(dbs) => dbs,
|
||||
Err(e) => {
|
||||
if let Some(ref tx) = observer_events_tx {
|
||||
let _ = tx.send(ObserverEvent::Error(format!(
|
||||
"Channel error: {:?}",
|
||||
e
|
||||
)));
|
||||
} else {
|
||||
ctx.try_log(|logger| {
|
||||
slog::error!(
|
||||
logger,
|
||||
"Unable to open readwtite connection",
|
||||
)
|
||||
});
|
||||
}
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
for block in new_blocks.iter_mut() {
|
||||
if let Err(e) = update_hord_db_and_augment_bitcoin_block(
|
||||
block,
|
||||
&blocks_db,
|
||||
&inscriptions_db_conn_rw,
|
||||
true,
|
||||
&config.get_cache_path_buf(),
|
||||
&traversals_cache,
|
||||
&ctx,
|
||||
) {
|
||||
ctx.try_log(|logger| {
|
||||
slog::error!(
|
||||
logger,
|
||||
"Unable to insert bitcoin block {} in hord_db: {e}",
|
||||
block.block_identifier.index
|
||||
)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
for header in data.confirmed_headers.iter() {
|
||||
match bitcoin_block_store.remove(&header.block_identifier) {
|
||||
Some(block) => {
|
||||
|
||||
Reference in New Issue
Block a user