Skip to content

Commit a8d76b0

Browse files
author
Ludo Galabru
committed
fix: don't early exit when satoshi computing fail
1 parent 802e6bb commit a8d76b0

File tree

1 file changed

+27
-5
lines changed
  • components/chainhook-event-observer/src/hord

1 file changed

+27
-5
lines changed

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

+27-5
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,27 @@ pub fn update_hord_db_and_augment_bitcoin_block(
247247
let mut traversals_received = 0;
248248
while let Ok((transaction_identifier, traversal_result)) = traversal_rx.recv() {
249249
traversals_received += 1;
250-
let traversal = traversal_result?;
251-
traversals.insert(transaction_identifier, traversal);
250+
match traversal_result {
251+
Ok(traversal) => {
252+
ctx.try_log(|logger| {
253+
slog::info!(
254+
logger,
255+
"Satoshi #{} was minted in block #{} at offset {} and was transferred {} times.",
256+
traversal.ordinal_number, traversal.get_ordinal_coinbase_height(), traversal.get_ordinal_coinbase_offset(), traversal.transfers
257+
)
258+
});
259+
traversals.insert(transaction_identifier, traversal);
260+
}
261+
Err(e) => {
262+
ctx.try_log(|logger| {
263+
slog::error!(
264+
logger,
265+
"Unable to compute inscription's Satoshi from transaction {}: {e}",
266+
transaction_identifier.hash
267+
)
268+
});
269+
}
270+
}
252271
if traversals_received == expected_traversals {
253272
break;
254273
}
@@ -446,9 +465,11 @@ pub fn update_storage_and_augment_bitcoin_block_with_inscription_transfer_data(
446465

447466
// Question is: are inscriptions moving to a new output,
448467
// burnt or lost in fees and transfered to the miner?
449-
468+
450469
let post_transfer_output: Option<usize> = loop {
451-
if sats_out_offset + next_output_value > sats_in_offset + watched_satpoint.offset {
470+
if sats_out_offset + next_output_value
471+
> sats_in_offset + watched_satpoint.offset
472+
{
452473
break Some(post_transfer_output_index);
453474
}
454475
sats_out_offset += next_output_value;
@@ -507,7 +528,8 @@ pub fn update_storage_and_augment_bitcoin_block_with_inscription_transfer_data(
507528
}
508529
None => {
509530
// Get Coinbase TX
510-
let offset = first_sat_post_subsidy + cumulated_fees + watched_satpoint.offset;
531+
let offset =
532+
first_sat_post_subsidy + cumulated_fees + watched_satpoint.offset;
511533
let outpoint = format!("{}:0", &coinbase_txid[2..]);
512534
(outpoint, offset, None, None)
513535
}

0 commit comments

Comments
 (0)