From fce694b461847b7a427a453cb10a002d7d236afd Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Thu, 14 Sep 2023 17:47:56 -0600 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Daira Emma Hopwood --- zcash_client_backend/proto/proposal.proto | 5 ++--- zcash_client_backend/src/fees.rs | 3 +++ zcash_client_backend/src/proto/proposal.rs | 5 ++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/zcash_client_backend/proto/proposal.proto b/zcash_client_backend/proto/proposal.proto index 6991164db5..3826f5719d 100644 --- a/zcash_client_backend/proto/proposal.proto +++ b/zcash_client_backend/proto/proposal.proto @@ -19,7 +19,7 @@ message Proposal { // The fee rule used in constructing this proposal FeeRule feeRule = 6; // The minimum number of confirmations required for transaction inputs to be selected. - // Each of the proposed inputs is know to have at least this many confirmations. + // Each of the proposed inputs must have at least this many confirmations. uint32 minConfirmations = 7; // The target height for which the proposal was constructed // @@ -71,8 +71,7 @@ enum FeeRule { Zip317 = 3; } -// The total value, fee amount, and change outputs of the proposed -// transaction +// The proposed change outputs and fee amount. message TransactionBalance { repeated ChangeValue proposedChange = 1; uint64 feeRequired = 2; diff --git a/zcash_client_backend/src/fees.rs b/zcash_client_backend/src/fees.rs index 2f72158d01..c217964bd5 100644 --- a/zcash_client_backend/src/fees.rs +++ b/zcash_client_backend/src/fees.rs @@ -54,6 +54,9 @@ impl ChangeValue { pub struct TransactionBalance { proposed_change: Vec, fee_required: NonNegativeAmount, + + // A cache for the sum of proposed change and fee; we compute it on construction anyway, so we + // cache the resulting value. total: NonNegativeAmount, } diff --git a/zcash_client_backend/src/proto/proposal.rs b/zcash_client_backend/src/proto/proposal.rs index bebee12d59..31d5d695f1 100644 --- a/zcash_client_backend/src/proto/proposal.rs +++ b/zcash_client_backend/src/proto/proposal.rs @@ -19,7 +19,7 @@ pub struct Proposal { #[prost(enumeration = "FeeRule", tag = "6")] pub fee_rule: i32, /// The minimum number of confirmations required for transaction inputs to be selected. - /// Each of the proposed inputs is know to have at least this many confirmations. + /// Each of the proposed inputs must have at least this many confirmations. #[prost(uint32, tag = "7")] pub min_confirmations: u32, /// The target height for which the proposal was constructed @@ -53,8 +53,7 @@ pub struct ProposedInput { #[prost(uint64, tag = "4")] pub value: u64, } -/// The total value, fee amount, and change outputs of the proposed -/// transaction +/// The proposed change outputs and fee amount. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct TransactionBalance {