mirror of
https://github.com/alexgo-io/bitcoin-indexer.git
synced 2026-01-12 22:43:06 +08:00
fix: transfer tracking
This commit is contained in:
@@ -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,
|
||||
@@ -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,
|
||||
@@ -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 {
|
||||
@@ -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);
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user