Skip to content

Commit

Permalink
fix: traversals algo
Browse files Browse the repository at this point in the history
  • Loading branch information
lgalabru committed May 11, 2023
1 parent 3494997 commit e8ee3ab
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions components/chainhook-event-observer/src/hord/db/mod.rs
Expand Up @@ -1558,22 +1558,14 @@ pub fn retrieve_satoshi_point_using_lazy_storage(
sats_in += input.txin_value;

if sats_out < sats_in {
traversals_cache.insert((ordinal_block_number, tx_cursor.0), lazy_tx.clone());
ordinal_offset = sats_out - (sats_in - input.txin_value);
ordinal_block_number = input.block_height;

ctx.try_log(|logger| slog::info!(logger, "Block {ordinal_block_number} / Tx {} / [in:{sats_in}, out:{sats_out}]: {} -> {ordinal_block_number}:{ordinal_offset} -> {}:{}",
hex::encode(&lazy_tx.txid),
input.block_height,
hex::encode(&input.txin),
input.vout,
));
tx_cursor = (input.txin.clone(), input.vout as usize);
break;
}
}

traversals_cache.insert((ordinal_block_number, tx_cursor.0), lazy_tx);

if sats_in == 0 {
ctx.try_log(|logger| {
slog::error!(
Expand Down Expand Up @@ -1607,14 +1599,14 @@ pub struct LazyBlock {
pub tx_len: u16,
}

#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct LazyBlockTransaction {
pub txid: [u8; 8],
pub inputs: Vec<LazyBlockTransactionInput>,
pub outputs: Vec<u64>,
}

#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct LazyBlockTransactionInput {
pub txin: [u8; 8],
pub block_height: u32,
Expand Down

0 comments on commit e8ee3ab

Please sign in to comment.