Skip to content

Commit ca93571

Browse files
committed
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.
1 parent 2a3bf03 commit ca93571

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lightning/src/chain/chaininterface.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,19 @@ pub const MIN_RELAY_FEE_SAT_PER_1000_WEIGHT: u64 = 4000;
6868
pub const FEERATE_FLOOR_SATS_PER_KW: u32 = 253;
6969

7070
/// Wraps a `Deref` to a `FeeEstimator` so that any fee estimations provided by it
71-
/// are bounded below by `FEERATE_FLOOR_SATS_PER_KW` (253 sats/KW)
71+
/// are bounded below by `FEERATE_FLOOR_SATS_PER_KW` (253 sats/KW).
72+
///
73+
/// Note that this does *not* implement [`FeeEstimator`] to make it harder to accidentally mix the
74+
/// two.
7275
pub(crate) struct LowerBoundedFeeEstimator<F: Deref>(pub F) where F::Target: FeeEstimator;
7376

7477
impl<F: Deref> LowerBoundedFeeEstimator<F> where F::Target: FeeEstimator {
7578
/// Creates a new `LowerBoundedFeeEstimator` which wraps the provided fee_estimator
7679
pub fn new(fee_estimator: F) -> Self {
7780
LowerBoundedFeeEstimator(fee_estimator)
7881
}
79-
}
8082

81-
impl<F: Deref> FeeEstimator for LowerBoundedFeeEstimator<F> where F::Target: FeeEstimator {
82-
fn get_est_sat_per_1000_weight(&self, confirmation_target: ConfirmationTarget) -> u32 {
83+
pub fn get_est_sat_per_1000_weight(&self, confirmation_target: ConfirmationTarget) -> u32 {
8384
cmp::max(
8485
self.0.get_est_sat_per_1000_weight(confirmation_target),
8586
FEERATE_FLOOR_SATS_PER_KW,

0 commit comments

Comments
 (0)