Skip to content

Commit af7e9b6

Browse files
committed
Change LowerBoundedFeeEstimator fn name to make it hard to swap
This change the method name on `LowerBoundedFeeEstimator` to further differentiate it from the generic `FeeEstimator` trait.
1 parent a491200 commit af7e9b6

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

lightning/src/chain/chaininterface.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl<F: Deref> LowerBoundedFeeEstimator<F> where F::Target: FeeEstimator {
7272
LowerBoundedFeeEstimator(fee_estimator)
7373
}
7474

75-
pub fn get_est_sat_per_1000_weight(&self, confirmation_target: ConfirmationTarget) -> u32 {
75+
pub fn bounded_sat_per_1000_weight(&self, confirmation_target: ConfirmationTarget) -> u32 {
7676
cmp::max(
7777
self.0.get_est_sat_per_1000_weight(confirmation_target),
7878
FEERATE_FLOOR_SATS_PER_KW,
@@ -100,7 +100,7 @@ mod tests {
100100
let test_fee_estimator = &TestFeeEstimator { sat_per_kw };
101101
let fee_estimator = LowerBoundedFeeEstimator::new(test_fee_estimator);
102102

103-
assert_eq!(fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Background), FEERATE_FLOOR_SATS_PER_KW);
103+
assert_eq!(fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::Background), FEERATE_FLOOR_SATS_PER_KW);
104104
}
105105

106106
#[test]
@@ -109,6 +109,6 @@ mod tests {
109109
let test_fee_estimator = &TestFeeEstimator { sat_per_kw };
110110
let fee_estimator = LowerBoundedFeeEstimator::new(test_fee_estimator);
111111

112-
assert_eq!(fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Background), sat_per_kw);
112+
assert_eq!(fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::Background), sat_per_kw);
113113
}
114114
}

lightning/src/chain/package.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -778,13 +778,13 @@ fn compute_fee_from_spent_amounts<F: Deref, L: Deref>(input_amounts: u64, predic
778778
where F::Target: FeeEstimator,
779779
L::Target: Logger,
780780
{
781-
let mut updated_feerate = fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::HighPriority) as u64;
781+
let mut updated_feerate = fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::HighPriority) as u64;
782782
let mut fee = updated_feerate * (predicted_weight as u64) / 1000;
783783
if input_amounts <= fee {
784-
updated_feerate = fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Normal) as u64;
784+
updated_feerate = fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::Normal) as u64;
785785
fee = updated_feerate * (predicted_weight as u64) / 1000;
786786
if input_amounts <= fee {
787-
updated_feerate = fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Background) as u64;
787+
updated_feerate = fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::Background) as u64;
788788
fee = updated_feerate * (predicted_weight as u64) / 1000;
789789
if input_amounts <= fee {
790790
log_error!(logger, "Failed to generate an on-chain punishment tx as even low priority fee ({} sat) was more than the entire claim balance ({} sat)",

lightning/src/ln/channel.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ impl<Signer: Sign> Channel<Signer> {
917917
return Err(APIError::APIMisuseError { err: format!("Holder selected channel reserve below implemention limit dust_limit_satoshis {}", holder_selected_channel_reserve_satoshis) });
918918
}
919919

920-
let feerate = fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Normal);
920+
let feerate = fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::Normal);
921921

922922
let value_to_self_msat = channel_value_satoshis * 1000 - push_msat;
923923
let commitment_tx_fee = Self::commit_tx_fee_msat(feerate, MIN_AFFORDABLE_HTLC_COUNT, opt_anchors);
@@ -1064,11 +1064,11 @@ impl<Signer: Sign> Channel<Signer> {
10641064
// We generally don't care too much if they set the feerate to something very high, but it
10651065
// could result in the channel being useless due to everything being dust.
10661066
let upper_limit = cmp::max(250 * 25,
1067-
fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::HighPriority) as u64 * 10);
1067+
fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::HighPriority) as u64 * 10);
10681068
if feerate_per_kw as u64 > upper_limit {
10691069
return Err(ChannelError::Close(format!("Peer's feerate much too high. Actual: {}. Our expected upper limit: {}", feerate_per_kw, upper_limit)));
10701070
}
1071-
let lower_limit = fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Background);
1071+
let lower_limit = fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::Background);
10721072
// Some fee estimators round up to the next full sat/vbyte (ie 250 sats per kw), causing
10731073
// occasional issues with feerate disagreements between an initiator that wants a feerate
10741074
// of 1.1 sat/vbyte and a receiver that wants 1.1 rounded up to 2. Thus, we always add 250
@@ -4022,8 +4022,8 @@ impl<Signer: Sign> Channel<Signer> {
40224022
// Propose a range from our current Background feerate to our Normal feerate plus our
40234023
// force_close_avoidance_max_fee_satoshis.
40244024
// If we fail to come to consensus, we'll have to force-close.
4025-
let mut proposed_feerate = fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Background);
4026-
let normal_feerate = fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Normal);
4025+
let mut proposed_feerate = fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::Background);
4026+
let normal_feerate = fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::Normal);
40274027
let mut proposed_max_feerate = if self.is_outbound() { normal_feerate } else { u32::max_value() };
40284028

40294029
// The spec requires that (when the channel does not have anchors) we only send absolute

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3577,7 +3577,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
35773577
PersistenceNotifierGuard::optionally_notify(&self.total_consistency_lock, &self.persistence_notifier, || {
35783578
let mut should_persist = NotifyOption::SkipPersist;
35793579

3580-
let new_feerate = self.fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Normal);
3580+
let new_feerate = self.fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::Normal);
35813581

35823582
let mut handle_errors = Vec::new();
35833583
{
@@ -3616,7 +3616,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
36163616
let mut should_persist = NotifyOption::SkipPersist;
36173617
if self.process_background_events() { should_persist = NotifyOption::DoPersist; }
36183618

3619-
let new_feerate = self.fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Normal);
3619+
let new_feerate = self.fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::Normal);
36203620

36213621
let mut handle_errors = Vec::new();
36223622
let mut timed_out_mpp_htlcs = Vec::new();

0 commit comments

Comments
 (0)