Skip to content

Commit

Permalink
chore: logs cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelcr committed Dec 4, 2024
1 parent 4050d9a commit 9a8b2c7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ use crate::{
},
pipeline::processors::block_archiving::store_compacted_blocks,
protocol::{
inscription_parsing::{
get_inscriptions_revealed_in_block, get_inscriptions_transferred_in_block,
parse_inscriptions_in_standardized_block,
},
inscription_parsing::parse_inscriptions_in_standardized_block,
inscription_sequencing::{
augment_block_with_inscriptions, get_bitcoin_network, get_jubilee_block_height,
parallelize_inscription_data_computations, SequenceCursor,
Expand Down Expand Up @@ -203,21 +200,6 @@ pub async fn process_blocks(
)
.await?;

Check warning on line 201 in components/ordhook-core/src/core/pipeline/processors/inscription_indexing.rs

View check run for this annotation

Codecov / codecov/patch

components/ordhook-core/src/core/pipeline/processors/inscription_indexing.rs#L201

Added line #L201 was not covered by tests

let inscriptions_revealed = get_inscriptions_revealed_in_block(&block)
.iter()
.map(|d| d.get_inscription_number().to_string())
.collect::<Vec<String>>();

let inscriptions_transferred = get_inscriptions_transferred_in_block(&block).len();

try_info!(
ctx,
"Block #{} processed, revealed {} inscriptions [{}] and {inscriptions_transferred} transfers",
block.block_identifier.index,
inscriptions_revealed.len(),
inscriptions_revealed.join(", ")
);

if let Some(post_processor_tx) = post_processor {
let _ = post_processor_tx.send(block.clone());
}
Expand All @@ -238,7 +220,10 @@ pub async fn process_block(
pg_pools: &PgConnectionPools,
ctx: &Context,
) -> Result<(), String> {
let stopwatch = std::time::Instant::now();
let block_height = block.block_identifier.index;
try_info!(ctx, "Indexing block #{block_height}");

Check warning on line 225 in components/ordhook-core/src/core/pipeline/processors/inscription_indexing.rs

View check run for this annotation

Codecov / codecov/patch

components/ordhook-core/src/core/pipeline/processors/inscription_indexing.rs#L223-L225

Added lines #L223 - L225 were not covered by tests

with_pg_transaction(&pg_pools.ordinals, |tx| async move {

Check warning on line 227 in components/ordhook-core/src/core/pipeline/processors/inscription_indexing.rs

View check run for this annotation

Codecov / codecov/patch

components/ordhook-core/src/core/pipeline/processors/inscription_indexing.rs#L227

Added line #L227 was not covered by tests
// Parsed BRC20 ops will be deposited here for this block.
let mut brc20_operation_map = HashMap::new();
Expand Down Expand Up @@ -289,7 +274,14 @@ pub async fn process_block(
);
Ok(())

Check warning on line 275 in components/ordhook-core/src/core/pipeline/processors/inscription_indexing.rs

View check run for this annotation

Codecov / codecov/patch

components/ordhook-core/src/core/pipeline/processors/inscription_indexing.rs#L275

Added line #L275 was not covered by tests
})
.await
.await?;

Check warning on line 277 in components/ordhook-core/src/core/pipeline/processors/inscription_indexing.rs

View check run for this annotation

Codecov / codecov/patch

components/ordhook-core/src/core/pipeline/processors/inscription_indexing.rs#L277

Added line #L277 was not covered by tests

try_info!(

Check warning on line 279 in components/ordhook-core/src/core/pipeline/processors/inscription_indexing.rs

View check run for this annotation

Codecov / codecov/patch

components/ordhook-core/src/core/pipeline/processors/inscription_indexing.rs#L279

Added line #L279 was not covered by tests
ctx,
"Block #{block_height} indexed in {}s",
stopwatch.elapsed().as_millis() as f32 / 1000.0
);
Ok(())
}

pub async fn rollback_block(

Check warning on line 287 in components/ordhook-core/src/core/pipeline/processors/inscription_indexing.rs

View check run for this annotation

Codecov / codecov/patch

components/ordhook-core/src/core/pipeline/processors/inscription_indexing.rs#L287

Added line #L287 was not covered by tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub fn parallelize_inscription_data_computations(
Context::empty()
};

try_info!(
try_debug!(
inner_ctx,
"Inscriptions data computation for block #{} started",
block.block_identifier.index
Expand Down Expand Up @@ -157,7 +157,7 @@ pub fn parallelize_inscription_data_computations(
.map(|b| format!("{}", b.block_identifier.index))
.collect::<Vec<_>>();

try_info!(
try_debug!(

Check warning on line 160 in components/ordhook-core/src/core/protocol/inscription_sequencing.rs

View check run for this annotation

Codecov / codecov/patch

components/ordhook-core/src/core/protocol/inscription_sequencing.rs#L160

Added line #L160 was not covered by tests
inner_ctx,
"Number of inscriptions in block #{} to process: {} (L1 cache hits: {}, queue: [{}], L1 cache len: {}, L2 cache len: {})",
block.block_identifier.index,
Expand Down Expand Up @@ -197,7 +197,7 @@ pub fn parallelize_inscription_data_computations(
}
match traversal_result {
Ok((traversal, inscription_pointer, _)) => {
try_info!(
try_debug!(

Check warning on line 200 in components/ordhook-core/src/core/protocol/inscription_sequencing.rs

View check run for this annotation

Codecov / codecov/patch

components/ordhook-core/src/core/protocol/inscription_sequencing.rs#L200

Added line #L200 was not covered by tests
inner_ctx,
"Completed ordinal number retrieval for Satpoint {}:{}:{} (block: #{}:{}, transfers: {}, progress: {traversals_received}/{expected_traversals}, priority queue: {prioritary}, thread: {thread_index})",
traversal.transaction_identifier_inscription.hash,
Expand Down Expand Up @@ -257,7 +257,7 @@ pub fn parallelize_inscription_data_computations(
}
}
}
try_info!(
try_debug!(
inner_ctx,
"Inscriptions data computation for block #{} collected",
block.block_identifier.index
Expand All @@ -268,7 +268,7 @@ pub fn parallelize_inscription_data_computations(
// Empty the queue
if let Ok((traversal_result, _prioritary, thread_index)) = traversal_rx.try_recv() {
if let Ok((traversal, inscription_pointer, _)) = traversal_result {
try_info!(
try_debug!(

Check warning on line 271 in components/ordhook-core/src/core/protocol/inscription_sequencing.rs

View check run for this annotation

Codecov / codecov/patch

components/ordhook-core/src/core/protocol/inscription_sequencing.rs#L271

Added line #L271 was not covered by tests
inner_ctx,
"Completed ordinal number retrieval for Satpoint {}:{}:{} (block: #{}:{}, transfers: {}, pre-retrieval, thread: {thread_index})",
traversal.transaction_identifier_inscription.hash,
Expand Down Expand Up @@ -297,7 +297,7 @@ pub fn parallelize_inscription_data_computations(
}
});

try_info!(
try_debug!(
inner_ctx,
"Inscriptions data computation for block #{} ended",
block.block_identifier.index
Expand Down Expand Up @@ -722,14 +722,12 @@ async fn augment_transaction_with_ordinals_inscriptions_data(

try_info!(
ctx,
"Inscription {} (#{}) detected on Satoshi {} (block #{}, {} transfers)",
"Inscription reveal {} (#{}) detected on Satoshi {} at block #{}",
inscription.inscription_id,
inscription.get_inscription_number(),
inscription.ordinal_number,
block_identifier.index,
inscription.transfers_pre_inscription,
);

sequence_cursor.increment(is_cursed, db_tx).await?;

Check warning on line 731 in components/ordhook-core/src/core/protocol/inscription_sequencing.rs

View check run for this annotation

Codecov / codecov/patch

components/ordhook-core/src/core/protocol/inscription_sequencing.rs#L731

Added line #L731 was not covered by tests
}
tx.metadata
Expand Down Expand Up @@ -851,6 +849,7 @@ pub async fn augment_block_with_pre_computed_ordinals_data(
let _ = augment_transaction_with_ordinal_transfers(

Check warning on line 849 in components/ordhook-core/src/core/protocol/inscription_sequencing.rs

View check run for this annotation

Codecov / codecov/patch

components/ordhook-core/src/core/protocol/inscription_sequencing.rs#L849

Added line #L849 was not covered by tests
tx,
tx_index,
&block.block_identifier,

Check warning on line 852 in components/ordhook-core/src/core/protocol/inscription_sequencing.rs

View check run for this annotation

Codecov / codecov/patch

components/ordhook-core/src/core/protocol/inscription_sequencing.rs#L852

Added line #L852 was not covered by tests
&network,
&coinbase_tx,
coinbase_subsidy,
Expand Down
17 changes: 13 additions & 4 deletions components/ordhook-core/src/core/protocol/satoshi_tracking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use chainhook_postgres::deadpool_postgres::Transaction;
use chainhook_sdk::{
bitcoincore_rpc_json::bitcoin::{Address, Network, ScriptBuf},
types::{
BitcoinBlockData, BitcoinTransactionData, OrdinalInscriptionTransferData,
OrdinalInscriptionTransferDestination, OrdinalOperation,
BitcoinBlockData, BitcoinTransactionData, BlockIdentifier, OrdinalInscriptionTransferData, OrdinalInscriptionTransferDestination, OrdinalOperation
},
utils::Context,
};
Expand Down Expand Up @@ -59,6 +58,7 @@ pub async fn augment_block_with_transfers(
let _ = augment_transaction_with_ordinal_transfers(
tx,
tx_index,
&block.block_identifier,

Check warning on line 61 in components/ordhook-core/src/core/protocol/satoshi_tracking.rs

View check run for this annotation

Codecov / codecov/patch

components/ordhook-core/src/core/protocol/satoshi_tracking.rs#L61

Added line #L61 was not covered by tests
&network,
&coinbase_tx,
coinbase_subsidy,
Expand Down Expand Up @@ -180,6 +180,7 @@ pub fn compute_satpoint_post_transfer(
pub async fn augment_transaction_with_ordinal_transfers(

Check warning on line 180 in components/ordhook-core/src/core/protocol/satoshi_tracking.rs

View check run for this annotation

Codecov / codecov/patch

components/ordhook-core/src/core/protocol/satoshi_tracking.rs#L180

Added line #L180 was not covered by tests
tx: &mut BitcoinTransactionData,
tx_index: usize,
block_identifier: &BlockIdentifier,
network: &Network,
coinbase_tx: &BitcoinTransactionData,
coinbase_subsidy: u64,
Expand Down Expand Up @@ -234,11 +235,19 @@ pub async fn augment_transaction_with_ordinal_transfers(
ordinal_number: watched_satpoint.ordinal_number,
destination,
tx_index,
satpoint_pre_transfer,
satpoint_post_transfer,
satpoint_pre_transfer: satpoint_pre_transfer.clone(),
satpoint_post_transfer: satpoint_post_transfer.clone(),

Check warning on line 239 in components/ordhook-core/src/core/protocol/satoshi_tracking.rs

View check run for this annotation

Codecov / codecov/patch

components/ordhook-core/src/core/protocol/satoshi_tracking.rs#L238-L239

Added lines #L238 - L239 were not covered by tests
post_transfer_output_value,
};

try_info!(

Check warning on line 243 in components/ordhook-core/src/core/protocol/satoshi_tracking.rs

View check run for this annotation

Codecov / codecov/patch

components/ordhook-core/src/core/protocol/satoshi_tracking.rs#L243

Added line #L243 was not covered by tests
ctx,
"Inscription transfer detected on Satoshi {} ({} -> {}) at block #{}",
transfer_data.ordinal_number,
satpoint_pre_transfer,
satpoint_post_transfer,
block_identifier.index
);
transfers.push(transfer_data.clone());
tx.metadata
.ordinal_operations
Expand Down

0 comments on commit 9a8b2c7

Please sign in to comment.