(db_path: &PathBuf)
| 26 | } |
| 27 | |
| 28 | fn 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 | |
| 73 | fn show_stats(db_path: &PathBuf) -> anyhow::Result<()> { |
| 74 | println!("=== Proof Cache Statistics ==="); |
no test coverage detected