MCPcopy Create free account
hub / github.com/consensus-shipyard/ipc / inspect_cache

Function inspect_cache

fendermint/app/src/cmd/proof_cache.rs:28–71  ·  view source on GitHub ↗
(db_path: &PathBuf)

Source from the content-addressed store, hash-verified

26}
27
28fn inspect_cache(db_path: &PathBuf) -> anyhow::Result<()> {
29 println!("=== Proof Cache Inspection ===");
30 println!("Database: {}", db_path.display());
31 println!();
32
33 let persistence = ProofCachePersistence::open(db_path)?;
34 let entries = persistence.load_all_entries()?;
35
36 if entries.is_empty() {
37 println!("\nCache is empty.");
38 return Ok(());
39 }
40
41 println!("\nEntries:");
42 println!(
43 "{:<12} {:<20} {:<15} {:<15}",
44 "Instance ID", "Epochs", "Proof Size", "Signers"
45 );
46 println!("{}", "-".repeat(70));
47
48 for entry in &entries {
49 let proof_size = entry
50 .proof_bundle
51 .as_ref()
52 .and_then(|bundle| fvm_ipld_encoding::to_vec(bundle).ok())
53 .map(|v| v.len())
54 .unwrap_or(0);
55
56 // Format strings needed for table alignment
57 #[allow(clippy::uninlined_format_args)]
58 let proof_size_str = format!("{proof_size} bytes");
59 #[allow(clippy::uninlined_format_args)]
60 let signers_str = format!("{} signers", entry.certificate.signers.len());
61 println!(
62 "{:<12} {:<20?} {:<15} {:<15}",
63 entry.certificate.gpbft_instance,
64 entry.certificate.ec_chain.suffix(),
65 proof_size_str,
66 signers_str
67 );
68 }
69
70 Ok(())
71}
72
73fn show_stats(db_path: &PathBuf) -> anyhow::Result<()> {
74 println!("=== Proof Cache Statistics ===");

Callers 1

Calls 6

openFunction · 0.85
load_all_entriesMethod · 0.80
okMethod · 0.80
is_emptyMethod · 0.45
as_refMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected