Skip to content

Commit 0ea85e3

Browse files
author
Ludo Galabru
committed
fix: transfer tracking
1 parent 72eb480 commit 0ea85e3

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

components/hord-cli/src/scan/bitcoin.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use crate::db::{
55
};
66
use crate::hord::{
77
self, get_inscriptions_revealed_in_block,
8-
update_storage_and_augment_bitcoin_block_with_inscription_reveal_data,
9-
update_storage_and_augment_bitcoin_block_with_inscription_transfer_data, Storage,
8+
update_storage_and_augment_bitcoin_block_with_inscription_reveal_data_tx,
9+
update_storage_and_augment_bitcoin_block_with_inscription_transfer_data_tx,
1010
};
1111
use crate::service::{
1212
open_readwrite_predicates_db_conn_or_panic, update_predicate_status, PredicateStatus,
@@ -25,7 +25,7 @@ use chainhook_sdk::indexer::bitcoin::{
2525
use chainhook_sdk::observer::{gather_proofs, EventObserverConfig};
2626
use chainhook_sdk::utils::{file_append, send_request, Context};
2727
use chainhook_types::{BitcoinBlockData, BitcoinChainEvent, BitcoinChainUpdatedWithBlocksData};
28-
use std::collections::{BTreeMap, HashMap};
28+
use std::collections::HashMap;
2929

3030
pub async fn scan_bitcoin_chainstate_via_rpc_using_predicate(
3131
predicate_spec: &BitcoinChainhookSpecification,
@@ -94,7 +94,6 @@ pub async fn scan_bitcoin_chainstate_via_rpc_using_predicate(
9494
let bitcoin_config = event_observer_config.get_bitcoin_config();
9595
let mut traversals = HashMap::new();
9696

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

10099
while cursor <= end_block {
@@ -125,7 +124,7 @@ pub async fn scan_bitcoin_chainstate_via_rpc_using_predicate(
125124
}
126125
};
127126

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

142-
let _ = update_storage_and_augment_bitcoin_block_with_inscription_reveal_data(
141+
let transaction = inscriptions_db_conn.transaction().unwrap();
142+
let empty_ctx = Context::empty();
143+
let _ = update_storage_and_augment_bitcoin_block_with_inscription_reveal_data_tx(
143144
&mut block,
144-
&mut storage,
145+
&transaction,
145146
&traversals,
146-
&inscriptions_db_conn,
147-
&ctx,
147+
&empty_ctx,
148148
)?;
149149

150-
let _ = update_storage_and_augment_bitcoin_block_with_inscription_transfer_data(
150+
let _ = update_storage_and_augment_bitcoin_block_with_inscription_transfer_data_tx(
151151
&mut block,
152-
&mut storage,
153-
&ctx,
152+
&transaction,
153+
&empty_ctx,
154154
)?;
155155

156156
let inscriptions_revealed = get_inscriptions_revealed_in_block(&block)

0 commit comments

Comments
 (0)