Skip to content

Commit

Permalink
chore: debug outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
medicz committed Dec 8, 2023
1 parent 8ce754a commit 657e4bc
Showing 1 changed file with 48 additions and 1 deletion.
49 changes: 48 additions & 1 deletion indexer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,20 @@ async fn handle_message(
) -> anyhow::Result<()> {
metrics::BLOCK_COUNT.inc();
metrics::LATEST_BLOCK_HEIGHT.set(streamer_message.block.header.height.try_into().unwrap());
info!(
target: crate::INDEXER_FOR_EXPLORER,
"Handle Message"
);

debug!(
target: INDEXER_FOR_EXPLORER,
"ReceiptsCache #{} \n {:#?}", streamer_message.block.header.height, &receipts_cache_arc
);
adapters::blocks::store_block(pool, &streamer_message.block).await?;
info!(
target: crate::INDEXER_FOR_EXPLORER,
"Stored block"
);

// Chunks
adapters::chunks::store_chunks(
Expand All @@ -43,6 +51,10 @@ async fn handle_message(
&streamer_message.block.header.hash,
)
.await?;
info!(
target: crate::INDEXER_FOR_EXPLORER,
"Stored Chunks"
);

// Transactions
let transactions_future = adapters::transactions::store_transactions(
Expand All @@ -53,6 +65,10 @@ async fn handle_message(
streamer_message.block.header.height,
receipts_cache_arc.clone(),
);
info!(
target: crate::INDEXER_FOR_EXPLORER,
"Stored Transactions"
);

// Receipts
let receipts_future = adapters::receipts::store_receipts(
Expand All @@ -63,13 +79,20 @@ async fn handle_message(
strict_mode,
receipts_cache_arc.clone(),
);

info!(
target: crate::INDEXER_FOR_EXPLORER,
"Stored Receipts"
);
// We can process transactions and receipts in parallel
// because most of receipts depend on transactions from previous blocks,
// so we can save up some time here.
// In case of local receipts (they are stored in the same block with corresponding transaction),
// we hope retry logic will cover it fine
try_join!(transactions_future, receipts_future)?;
info!(
target: crate::INDEXER_FOR_EXPLORER,
"Joined futures"
);

// ExecutionOutcomes
let execution_outcomes_future = adapters::execution_outcomes::store_execution_outcomes(
Expand All @@ -78,6 +101,10 @@ async fn handle_message(
streamer_message.block.header.timestamp,
receipts_cache_arc.clone(),
);
info!(
target: crate::INDEXER_FOR_EXPLORER,
"Stored Outcomes"
);

// Accounts
let accounts_future = async {
Expand All @@ -91,9 +118,17 @@ async fn handle_message(

try_join_all(futures).await.map(|_| ())
};
info!(
target: crate::INDEXER_FOR_EXPLORER,
"Stored accounts"
);

// Event-based entities (FT, NFT)
let assets_events_future = adapters::assets::events::store_events(pool, &streamer_message);
info!(
target: crate::INDEXER_FOR_EXPLORER,
"Stored Events"
);

if strict_mode {
// AccessKeys
Expand All @@ -108,6 +143,10 @@ async fn handle_message(

try_join_all(futures).await.map(|_| ())
};
info!(
target: crate::INDEXER_FOR_EXPLORER,
"Stored Keys"
);

// StateChange related to Account
#[cfg(feature = "account_changes")]
Expand All @@ -133,12 +172,20 @@ async fn handle_message(
access_keys_future,
assets_events_future,
)?;
info!(
target: crate::INDEXER_FOR_EXPLORER,
"Joined Changes"
);
} else {
try_join!(
execution_outcomes_future,
accounts_future,
assets_events_future
)?;
info!(
target: crate::INDEXER_FOR_EXPLORER,
"Joined All"
);
}

Ok(())
Expand Down

0 comments on commit 657e4bc

Please sign in to comment.