From eaec2435c0472e8e7d0b994a6a1d632e2365bffa Mon Sep 17 00:00:00 2001 From: Henry de Valence Date: Sat, 16 Mar 2024 10:16:41 -0700 Subject: [PATCH] pcli: show action / proof count before building This helps slightly in case there are many many actions, currently the user only finds out how many there were _after_ doing all the proving. --- crates/bin/pcli/src/network.rs | 6 +++++- crates/core/transaction/src/plan.rs | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/crates/bin/pcli/src/network.rs b/crates/bin/pcli/src/network.rs index 553f3443ff..ac2b17b220 100644 --- a/crates/bin/pcli/src/network.rs +++ b/crates/bin/pcli/src/network.rs @@ -45,7 +45,11 @@ impl App { &mut self, plan: TransactionPlan, ) -> impl Future> + '_ { - println!("building transaction..."); + println!( + "building transaction [{} actions, {} proofs]...", + plan.actions.len(), + plan.num_proofs(), + ); let start = std::time::Instant::now(); let tx = penumbra_wallet::build_transaction( &self.config.full_viewing_key, diff --git a/crates/core/transaction/src/plan.rs b/crates/core/transaction/src/plan.rs index a383447a40..dbbb70931e 100644 --- a/crates/core/transaction/src/plan.rs +++ b/crates/core/transaction/src/plan.rs @@ -331,6 +331,22 @@ impl TransactionPlan { self.spend_plans().count() } + /// Convenience method to get the number of proofs in this transaction. + pub fn num_proofs(&self) -> usize { + self.actions + .iter() + .map(|action| match action { + ActionPlan::Spend(_) => 1, + ActionPlan::Output(_) => 1, + ActionPlan::Swap(_) => 1, + ActionPlan::SwapClaim(_) => 1, + ActionPlan::UndelegateClaim(_) => 1, + ActionPlan::DelegatorVote(_) => 1, + _ => 0, + }) + .sum() + } + /// Method to populate the detection data for this transaction plan. pub fn populate_detection_data( &mut self,