mirror of
https://github.com/alexgo-io/bitcoin-indexer.git
synced 2026-06-13 16:19:01 +08:00
fix: address non-inscribed block case
This commit is contained in:
@@ -566,7 +566,7 @@ pub async fn fetch_and_cache_blocks_in_hord_db(
|
||||
let (block_hash_tx, block_hash_rx) = crossbeam_channel::bounded(128);
|
||||
let retrieve_block_data_pool = ThreadPool::new(network_thread);
|
||||
let (block_data_tx, block_data_rx) = crossbeam_channel::bounded(64);
|
||||
let compress_block_data_pool = ThreadPool::new(8);
|
||||
let compress_block_data_pool = ThreadPool::new(16);
|
||||
let (block_compressed_tx, block_compressed_rx) = crossbeam_channel::bounded(32);
|
||||
let first_inscription_block_height = 767430;
|
||||
|
||||
@@ -635,8 +635,6 @@ pub async fn fetch_and_cache_blocks_in_hord_db(
|
||||
let mut inbox = HashMap::new();
|
||||
|
||||
while let Ok(Some((block_height, compacted_block, raw_block))) = block_compressed_rx.recv() {
|
||||
ctx.try_log(|logger| slog::info!(logger, "Storing compacted block #{block_height}"));
|
||||
|
||||
insert_entry_in_blocks(block_height, &compacted_block, &rw_hord_db_conn, &ctx);
|
||||
blocks_stored += 1;
|
||||
|
||||
@@ -660,6 +658,7 @@ pub async fn fetch_and_cache_blocks_in_hord_db(
|
||||
// Is the action of processing a block allows us
|
||||
// to process more blocks present in the inbox?
|
||||
while let Some(next_block) = inbox.remove(&cursor) {
|
||||
ctx.try_log(|logger| slog::info!(logger, "Processing block #{cursor}"));
|
||||
let mut new_block = match standardize_bitcoin_block(next_block, &bitcoin_network, &ctx)
|
||||
{
|
||||
Ok(block) => block,
|
||||
|
||||
@@ -104,43 +104,44 @@ pub fn update_hord_db_and_augment_bitcoin_block(
|
||||
let mut transactions_ids = vec![];
|
||||
for new_tx in new_block.transactions.iter_mut().skip(1) {
|
||||
// Have a new inscription been revealed, if so, are looking at a re-inscription
|
||||
for ordinal_event in
|
||||
new_tx.metadata.ordinal_operations.iter_mut()
|
||||
{
|
||||
for ordinal_event in new_tx.metadata.ordinal_operations.iter_mut() {
|
||||
if let OrdinalOperation::InscriptionRevealed(_) = ordinal_event {
|
||||
transactions_ids.push(new_tx.transaction_identifier.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
let expected_traversals = transactions_ids.len();
|
||||
let (traversal_tx, traversal_rx) = channel::<(TransactionIdentifier, TraversalResult)>();
|
||||
let traversal_data_pool = ThreadPool::new(10);
|
||||
|
||||
for transaction_id in transactions_ids.into_iter() {
|
||||
let moved_traversal_tx = traversal_tx.clone();
|
||||
let moved_ctx = ctx.clone();
|
||||
let block_identifier = new_block.block_identifier.clone();
|
||||
let hord_db_path = hord_db_path.clone();
|
||||
traversal_data_pool.execute(move || {
|
||||
let hord_db_conn = open_readonly_hord_db_conn(&hord_db_path, &moved_ctx).unwrap();
|
||||
let traversal = retrieve_satoshi_point_using_local_storage(
|
||||
&hord_db_conn,
|
||||
&block_identifier,
|
||||
&transaction_id,
|
||||
&moved_ctx,
|
||||
)
|
||||
.unwrap();
|
||||
let _ = moved_traversal_tx.send((transaction_id, traversal));
|
||||
});
|
||||
}
|
||||
|
||||
let mut traversals = HashMap::new();
|
||||
let mut traversals_received = 0;
|
||||
while let Ok((transaction_identifier, traversal_result)) = traversal_rx.recv() {
|
||||
traversals_received += 1;
|
||||
traversals.insert(transaction_identifier, traversal_result);
|
||||
if traversals_received == expected_traversals {
|
||||
break;
|
||||
if !transactions_ids.is_empty() {
|
||||
let expected_traversals = transactions_ids.len();
|
||||
let (traversal_tx, traversal_rx) = channel::<(TransactionIdentifier, TraversalResult)>();
|
||||
let traversal_data_pool = ThreadPool::new(10);
|
||||
|
||||
for transaction_id in transactions_ids.into_iter() {
|
||||
let moved_traversal_tx = traversal_tx.clone();
|
||||
let moved_ctx = ctx.clone();
|
||||
let block_identifier = new_block.block_identifier.clone();
|
||||
let hord_db_path = hord_db_path.clone();
|
||||
traversal_data_pool.execute(move || {
|
||||
let hord_db_conn = open_readonly_hord_db_conn(&hord_db_path, &moved_ctx).unwrap();
|
||||
let traversal = retrieve_satoshi_point_using_local_storage(
|
||||
&hord_db_conn,
|
||||
&block_identifier,
|
||||
&transaction_id,
|
||||
&moved_ctx,
|
||||
)
|
||||
.unwrap();
|
||||
let _ = moved_traversal_tx.send((transaction_id, traversal));
|
||||
});
|
||||
}
|
||||
|
||||
let mut traversals_received = 0;
|
||||
while let Ok((transaction_identifier, traversal_result)) = traversal_rx.recv() {
|
||||
traversals_received += 1;
|
||||
traversals.insert(transaction_identifier, traversal_result);
|
||||
if traversals_received == expected_traversals {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user