From: Matt Corallo Date: Wed, 13 Jul 2022 16:52:27 +0000 (+0000) Subject: Use a separate (non-trait) fee-estimation fn in LowerBoundedEstimator X-Git-Tag: v0.0.110~5^2~2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=ca9357147e521a15702d1f05c687c54f9a65bf2b;p=rust-lightning Use a separate (non-trait) fee-estimation fn in LowerBoundedEstimator This should make it somewhat more difficult to accidentally use a straight fee estimator when we actually want a LowerBoundedFeeEstimator by not having the types be exchangeable at all. --- diff --git a/lightning/src/chain/chaininterface.rs b/lightning/src/chain/chaininterface.rs index 2ec7f318f..ab659cbca 100644 --- a/lightning/src/chain/chaininterface.rs +++ b/lightning/src/chain/chaininterface.rs @@ -68,7 +68,10 @@ pub const MIN_RELAY_FEE_SAT_PER_1000_WEIGHT: u64 = 4000; pub const FEERATE_FLOOR_SATS_PER_KW: u32 = 253; /// Wraps a `Deref` to a `FeeEstimator` so that any fee estimations provided by it -/// are bounded below by `FEERATE_FLOOR_SATS_PER_KW` (253 sats/KW) +/// are bounded below by `FEERATE_FLOOR_SATS_PER_KW` (253 sats/KW). +/// +/// Note that this does *not* implement [`FeeEstimator`] to make it harder to accidentally mix the +/// two. pub(crate) struct LowerBoundedFeeEstimator(pub F) where F::Target: FeeEstimator; impl LowerBoundedFeeEstimator where F::Target: FeeEstimator { @@ -76,10 +79,8 @@ impl LowerBoundedFeeEstimator where F::Target: FeeEstimator { pub fn new(fee_estimator: F) -> Self { LowerBoundedFeeEstimator(fee_estimator) } -} -impl FeeEstimator for LowerBoundedFeeEstimator where F::Target: FeeEstimator { - fn get_est_sat_per_1000_weight(&self, confirmation_target: ConfirmationTarget) -> u32 { + pub fn get_est_sat_per_1000_weight(&self, confirmation_target: ConfirmationTarget) -> u32 { cmp::max( self.0.get_est_sat_per_1000_weight(confirmation_target), FEERATE_FLOOR_SATS_PER_KW,