From 642c414f56b03222d25fb9f11260029c5ffb6a9a Mon Sep 17 00:00:00 2001 From: yancy Date: Tue, 13 May 2025 15:13:36 -0500 Subject: [PATCH] refactor: Use map combinator instead of match --- bitcoin/src/blockdata/transaction.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/bitcoin/src/blockdata/transaction.rs b/bitcoin/src/blockdata/transaction.rs index 7fd033604..18c3a8eb7 100644 --- a/bitcoin/src/blockdata/transaction.rs +++ b/bitcoin/src/blockdata/transaction.rs @@ -786,12 +786,10 @@ pub fn effective_value( ) -> NumOpResult { let weight = input_weight_prediction.total_weight(); - let fee = match fee_rate.to_fee(weight) { - NumOpResult::Valid(x) => x.to_signed(), - NumOpResult::Error(e) => return NumOpResult::Error(e) - }; - - value.to_signed() - fee // Cannot overflow. + fee_rate + .to_fee(weight) + .map(Amount::to_signed) + .and_then(|fee| value.to_signed() - fee) // Cannot overflow. } /// Predicts the weight of a to-be-constructed transaction.