Skip to content

Commit

Permalink
feat: add Firehose logs
Browse files Browse the repository at this point in the history
  • Loading branch information
xJonathanLEI committed Dec 13, 2023
1 parent 5f40c3f commit ff88c1b
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions crates/pathfinder/src/state/sync/l2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,60 @@ where
);
let signature = signature.into();

// Firehose integration
// TODO: add runtime option to toggle this on and off
{
use starknet_gateway_types::reply::transaction::Transaction;

println!("FIRE BLOCK_BEGIN {}", block.block_number);

for (ind_tx, tx) in block.transactions.iter().enumerate() {
println!(
"FIRE BEGIN_TRX {} {}",
tx.hash().0,
match tx {
Transaction::Declare(_) => "DECLARE",
Transaction::Deploy(_) => "DEPLOY",
Transaction::DeployAccount(_) => "DEPLOY_ACCOUNT",
Transaction::Invoke(_) => "INVOKE_FUNCTION",
Transaction::L1Handler(_) => "L1_HANDLER",
}
);

for (ind_event, event) in
block.transaction_receipts[ind_tx].events.iter().enumerate()
{
println!(
"FIRE TRX_BEGIN_EVENT {} {}",
tx.hash().0,
event.from_address.0
);

for key in event.keys.iter() {
println!("FIRE TRX_EVENT_KEY {} {} {}", tx.hash().0, ind_event, key.0);
}

for data in event.data.iter() {
println!(
"FIRE TRX_EVENT_DATA {} {} {}",
tx.hash().0,
ind_event,
data.0
);
}
}
}

println!(
"FIRE BLOCK_END {} {} {} {} {}",
block.block_number,
block.block_hash.0,
block.parent_block_hash.0,
block.timestamp,
block.transactions.len(),
);
}

head = Some((next, block_hash, state_update.state_commitment));
blocks.push(next, block_hash, state_update.state_commitment);

Expand Down

0 comments on commit ff88c1b

Please sign in to comment.