Skip to content

Commit

Permalink
fix: transfer tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
Ludo Galabru committed Jul 14, 2023
1 parent 72eb480 commit 0ea85e3
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions components/hord-cli/src/scan/bitcoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use crate::db::{
};
use crate::hord::{
self, get_inscriptions_revealed_in_block,
update_storage_and_augment_bitcoin_block_with_inscription_reveal_data,
update_storage_and_augment_bitcoin_block_with_inscription_transfer_data, Storage,
update_storage_and_augment_bitcoin_block_with_inscription_reveal_data_tx,
update_storage_and_augment_bitcoin_block_with_inscription_transfer_data_tx,
};
use crate::service::{
open_readwrite_predicates_db_conn_or_panic, update_predicate_status, PredicateStatus,
Expand All @@ -25,7 +25,7 @@ use chainhook_sdk::indexer::bitcoin::{
use chainhook_sdk::observer::{gather_proofs, EventObserverConfig};
use chainhook_sdk::utils::{file_append, send_request, Context};
use chainhook_types::{BitcoinBlockData, BitcoinChainEvent, BitcoinChainUpdatedWithBlocksData};
use std::collections::{BTreeMap, HashMap};
use std::collections::HashMap;

pub async fn scan_bitcoin_chainstate_via_rpc_using_predicate(
predicate_spec: &BitcoinChainhookSpecification,
Expand Down Expand Up @@ -94,7 +94,6 @@ pub async fn scan_bitcoin_chainstate_via_rpc_using_predicate(
let bitcoin_config = event_observer_config.get_bitcoin_config();
let mut traversals = HashMap::new();

let mut storage = Storage::Memory(BTreeMap::new());
let mut cursor = start_block.saturating_sub(1);

while cursor <= end_block {
Expand Down Expand Up @@ -125,7 +124,7 @@ pub async fn scan_bitcoin_chainstate_via_rpc_using_predicate(
}
};

if let Some(ref inscriptions_db_conn) = inscriptions_db_conn {
if let Some(ref mut inscriptions_db_conn) = inscriptions_db_conn {
// Evaluating every single block is required for also keeping track of transfers.
let local_traverals =
find_all_inscriptions_in_block(&cursor, &inscriptions_db_conn, &ctx);
Expand All @@ -139,18 +138,19 @@ pub async fn scan_bitcoin_chainstate_via_rpc_using_predicate(
);
}

let _ = update_storage_and_augment_bitcoin_block_with_inscription_reveal_data(
let transaction = inscriptions_db_conn.transaction().unwrap();
let empty_ctx = Context::empty();
let _ = update_storage_and_augment_bitcoin_block_with_inscription_reveal_data_tx(
&mut block,
&mut storage,
&transaction,
&traversals,
&inscriptions_db_conn,
&ctx,
&empty_ctx,
)?;

let _ = update_storage_and_augment_bitcoin_block_with_inscription_transfer_data(
let _ = update_storage_and_augment_bitcoin_block_with_inscription_transfer_data_tx(
&mut block,
&mut storage,
&ctx,
&transaction,
&empty_ctx,
)?;

let inscriptions_revealed = get_inscriptions_revealed_in_block(&block)
Expand Down

0 comments on commit 0ea85e3

Please sign in to comment.