Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 55 additions & 16 deletions common/examples/test_streaming_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,28 +275,67 @@ impl SnapshotCallbacks for CountingCallbacks {
impl SnapshotsCallback for CountingCallbacks {
fn on_snapshots(&mut self, snapshots: RawSnapshotsContainer) -> Result<()> {
eprintln!("Raw Snapshots Data:");
eprintln!();

// Calculate total stakes and delegator counts from VMap data
let mark_total: i64 = snapshots.mark.0.iter().map(|(_, amount)| amount).sum();
let set_total: i64 = snapshots.set.0.iter().map(|(_, amount)| amount).sum();
let go_total: i64 = snapshots.go.0.iter().map(|(_, amount)| amount).sum();

eprintln!(
" Mark snapshot: {} delegators, {} total stake (ADA)",
snapshots.mark.0.len(),
mark_total as f64 / 1_000_000.0
);
eprintln!(
" Set snapshot: {} delegators, {} total stake (ADA)",
snapshots.set.0.len(),
set_total as f64 / 1_000_000.0
);
eprintln!(
" Go snapshot: {} delegators, {} total stake (ADA)",
snapshots.go.0.len(),
go_total as f64 / 1_000_000.0
);
eprintln!(" Fee: {} ADA", snapshots.fee as f64 / 1_000_000.0);
eprintln!("Mark Snapshot:");
eprintln!(" Delegators: {}", snapshots.mark.0.len());
eprintln!(" Total stake: {:.2} ADA", mark_total as f64 / 1_000_000.0);
if !snapshots.mark.0.is_empty() {
eprintln!(" Sample stakes (first 5):");
for (i, (cred, amount)) in snapshots.mark.0.iter().take(5).enumerate() {
let cred_str = cred.to_string().unwrap_or_default();
eprintln!(
" [{}] {} -> {:.2} ADA",
i + 1,
cred_str,
*amount as f64 / 1_000_000.0
);
}
}
eprintln!();

eprintln!("Set Snapshot:");
eprintln!(" Delegators: {}", snapshots.set.0.len());
eprintln!(" Total stake: {:.2} ADA", set_total as f64 / 1_000_000.0);
if !snapshots.set.0.is_empty() {
eprintln!(" Sample stakes (first 5):");
for (i, (cred, amount)) in snapshots.set.0.iter().take(5).enumerate() {
let cred_str = cred.to_string().unwrap_or_default();
eprintln!(
" [{}] {} -> {:.2} ADA",
i + 1,
cred_str,
*amount as f64 / 1_000_000.0
);
}
}
eprintln!();

eprintln!("Go Snapshot:");
eprintln!(" Delegators: {}", snapshots.go.0.len());
eprintln!(" Total stake: {:.2} ADA", go_total as f64 / 1_000_000.0);
if !snapshots.go.0.is_empty() {
eprintln!(" Sample stakes (first 5):");
for (i, (cred, amount)) in snapshots.go.0.iter().take(5).enumerate() {
let cred_str = cred.to_string().unwrap_or_default();
eprintln!(
" [{}] {} -> {:.2} ADA",
i + 1,
cred_str,
*amount as f64 / 1_000_000.0
);
}
}
eprintln!();

eprintln!("Fee: {:.2} ADA", snapshots.fee as f64 / 1_000_000.0);
eprintln!();

Ok(())
}
}
Expand Down
Loading