mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-02-25 15:20:24 +01:00
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.
This commit is contained in:
parent
a491200f96
commit
af7e9b608d
4 changed files with 13 additions and 13 deletions
|
@ -72,7 +72,7 @@ impl<F: Deref> LowerBoundedFeeEstimator<F> where F::Target: FeeEstimator {
|
|||
LowerBoundedFeeEstimator(fee_estimator)
|
||||
}
|
||||
|
||||
pub fn get_est_sat_per_1000_weight(&self, confirmation_target: ConfirmationTarget) -> u32 {
|
||||
pub fn bounded_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,
|
||||
|
@ -100,7 +100,7 @@ mod tests {
|
|||
let test_fee_estimator = &TestFeeEstimator { sat_per_kw };
|
||||
let fee_estimator = LowerBoundedFeeEstimator::new(test_fee_estimator);
|
||||
|
||||
assert_eq!(fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Background), FEERATE_FLOOR_SATS_PER_KW);
|
||||
assert_eq!(fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::Background), FEERATE_FLOOR_SATS_PER_KW);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -109,6 +109,6 @@ mod tests {
|
|||
let test_fee_estimator = &TestFeeEstimator { sat_per_kw };
|
||||
let fee_estimator = LowerBoundedFeeEstimator::new(test_fee_estimator);
|
||||
|
||||
assert_eq!(fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Background), sat_per_kw);
|
||||
assert_eq!(fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::Background), sat_per_kw);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -778,13 +778,13 @@ fn compute_fee_from_spent_amounts<F: Deref, L: Deref>(input_amounts: u64, predic
|
|||
where F::Target: FeeEstimator,
|
||||
L::Target: Logger,
|
||||
{
|
||||
let mut updated_feerate = fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::HighPriority) as u64;
|
||||
let mut updated_feerate = fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::HighPriority) as u64;
|
||||
let mut fee = updated_feerate * (predicted_weight as u64) / 1000;
|
||||
if input_amounts <= fee {
|
||||
updated_feerate = fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Normal) as u64;
|
||||
updated_feerate = fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::Normal) as u64;
|
||||
fee = updated_feerate * (predicted_weight as u64) / 1000;
|
||||
if input_amounts <= fee {
|
||||
updated_feerate = fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Background) as u64;
|
||||
updated_feerate = fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::Background) as u64;
|
||||
fee = updated_feerate * (predicted_weight as u64) / 1000;
|
||||
if input_amounts <= fee {
|
||||
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)",
|
||||
|
|
|
@ -917,7 +917,7 @@ impl<Signer: Sign> Channel<Signer> {
|
|||
return Err(APIError::APIMisuseError { err: format!("Holder selected channel reserve below implemention limit dust_limit_satoshis {}", holder_selected_channel_reserve_satoshis) });
|
||||
}
|
||||
|
||||
let feerate = fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Normal);
|
||||
let feerate = fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::Normal);
|
||||
|
||||
let value_to_self_msat = channel_value_satoshis * 1000 - push_msat;
|
||||
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> {
|
|||
// We generally don't care too much if they set the feerate to something very high, but it
|
||||
// could result in the channel being useless due to everything being dust.
|
||||
let upper_limit = cmp::max(250 * 25,
|
||||
fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::HighPriority) as u64 * 10);
|
||||
fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::HighPriority) as u64 * 10);
|
||||
if feerate_per_kw as u64 > upper_limit {
|
||||
return Err(ChannelError::Close(format!("Peer's feerate much too high. Actual: {}. Our expected upper limit: {}", feerate_per_kw, upper_limit)));
|
||||
}
|
||||
let lower_limit = fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Background);
|
||||
let lower_limit = fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::Background);
|
||||
// Some fee estimators round up to the next full sat/vbyte (ie 250 sats per kw), causing
|
||||
// occasional issues with feerate disagreements between an initiator that wants a feerate
|
||||
// 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> {
|
|||
// Propose a range from our current Background feerate to our Normal feerate plus our
|
||||
// force_close_avoidance_max_fee_satoshis.
|
||||
// If we fail to come to consensus, we'll have to force-close.
|
||||
let mut proposed_feerate = fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Background);
|
||||
let normal_feerate = fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Normal);
|
||||
let mut proposed_feerate = fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::Background);
|
||||
let normal_feerate = fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::Normal);
|
||||
let mut proposed_max_feerate = if self.is_outbound() { normal_feerate } else { u32::max_value() };
|
||||
|
||||
// The spec requires that (when the channel does not have anchors) we only send absolute
|
||||
|
|
|
@ -3577,7 +3577,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
|
|||
PersistenceNotifierGuard::optionally_notify(&self.total_consistency_lock, &self.persistence_notifier, || {
|
||||
let mut should_persist = NotifyOption::SkipPersist;
|
||||
|
||||
let new_feerate = self.fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Normal);
|
||||
let new_feerate = self.fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::Normal);
|
||||
|
||||
let mut handle_errors = Vec::new();
|
||||
{
|
||||
|
@ -3616,7 +3616,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
|
|||
let mut should_persist = NotifyOption::SkipPersist;
|
||||
if self.process_background_events() { should_persist = NotifyOption::DoPersist; }
|
||||
|
||||
let new_feerate = self.fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Normal);
|
||||
let new_feerate = self.fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::Normal);
|
||||
|
||||
let mut handle_errors = Vec::new();
|
||||
let mut timed_out_mpp_htlcs = Vec::new();
|
||||
|
|
Loading…
Add table
Reference in a new issue