Skip to content

Commit d41bc6d

Browse files
committed
ln/refactor: add prefix to commitment_sat_per_1000_weight_for_type
1 parent eae2bb1 commit d41bc6d

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

lightning/src/ln/chan_utils.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,9 @@ pub(crate) fn htlc_tx_fees_sat(feerate_per_kw: u32, num_accepted_htlcs: usize, n
260260
num_accepted_htlcs as u64 * htlc_success_tx_fee_sat + num_offered_htlcs as u64 * htlc_timeout_tx_fee_sat
261261
}
262262

263-
/// Returns a fee estimate for the commitment transaction depending on channel type.
264-
pub(super) fn commitment_sat_per_1000_weight_for_type<F: Deref>(
263+
/// Returns a fee estimate for the commitment transaction that we would ideally like to set,
264+
/// depending on channel type.
265+
pub(super) fn selected_commitment_sat_per_1000_weight<F: Deref>(
265266
fee_estimator: &LowerBoundedFeeEstimator<F>, channel_type: &ChannelTypeFeatures,
266267
) -> u32
267268
where

lightning/src/ln/channel.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ use crate::ln::chan_utils;
4141
#[cfg(splicing)]
4242
use crate::ln::chan_utils::FUNDING_TRANSACTION_WITNESS_WEIGHT;
4343
use crate::ln::chan_utils::{
44-
commitment_sat_per_1000_weight_for_type, get_commitment_transaction_number_obscure_factor,
45-
max_htlcs, second_stage_tx_fees_sat, ChannelPublicKeys, ChannelTransactionParameters,
44+
get_commitment_transaction_number_obscure_factor, max_htlcs, second_stage_tx_fees_sat,
45+
selected_commitment_sat_per_1000_weight, ChannelPublicKeys, ChannelTransactionParameters,
4646
ClosingTransaction, CommitmentTransaction, CounterpartyChannelTransactionParameters,
4747
CounterpartyCommitmentSecrets, HTLCOutputInCommitment, HolderCommitmentTransaction,
4848
};
@@ -3392,7 +3392,9 @@ where
33923392
debug_assert!(!channel_type.supports_any_optional_bits());
33933393
debug_assert!(!channel_type.requires_unknown_bits_from(&channelmanager::provided_channel_type_features(&config)));
33943394

3395-
let commitment_feerate = commitment_sat_per_1000_weight_for_type(&fee_estimator, &channel_type);
3395+
let commitment_feerate = selected_commitment_sat_per_1000_weight(
3396+
&fee_estimator, &channel_type,
3397+
);
33963398

33973399
let value_to_self_msat = channel_value_satoshis * 1000 - push_msat;
33983400
let commit_tx_fee_sat = SpecTxBuilder {}.commit_tx_fee_sat(commitment_feerate, MIN_AFFORDABLE_HTLC_COUNT, &channel_type);
@@ -5460,7 +5462,9 @@ where
54605462

54615463
let next_channel_type = get_initial_channel_type(user_config, &eligible_features);
54625464

5463-
self.feerate_per_kw = commitment_sat_per_1000_weight_for_type(&fee_estimator, &next_channel_type);
5465+
self.feerate_per_kw = selected_commitment_sat_per_1000_weight(
5466+
&fee_estimator, &next_channel_type,
5467+
);
54645468
funding.channel_transaction_parameters.channel_type_features = next_channel_type;
54655469

54665470
Ok(())

lightning/src/ln/channelmanager.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ use crate::events::{
5656
InboundChannelFunds, PaymentFailureReason, ReplayEvent,
5757
};
5858
use crate::events::{FundingInfo, PaidBolt12Invoice};
59-
use crate::ln::chan_utils::commitment_sat_per_1000_weight_for_type;
59+
use crate::ln::chan_utils::selected_commitment_sat_per_1000_weight;
6060
// Since this struct is returned in `list_channels` methods, expose it here in case users want to
6161
// construct one themselves.
6262
use crate::ln::channel::PendingV2Channel;
@@ -7231,7 +7231,9 @@ where
72317231
for (chan_id, chan) in peer_state.channel_by_id.iter_mut()
72327232
.filter_map(|(chan_id, chan)| chan.as_funded_mut().map(|chan| (chan_id, chan)))
72337233
{
7234-
let new_feerate = commitment_sat_per_1000_weight_for_type(&self.fee_estimator, chan.funding.get_channel_type());
7234+
let new_feerate = selected_commitment_sat_per_1000_weight(
7235+
&self.fee_estimator, chan.funding.get_channel_type(),
7236+
);
72357237
let chan_needs_persist = self.update_channel_fee(chan_id, chan, new_feerate);
72367238
if chan_needs_persist == NotifyOption::DoPersist { should_persist = NotifyOption::DoPersist; }
72377239
}
@@ -7280,7 +7282,9 @@ where
72807282
peer_state.channel_by_id.retain(|chan_id, chan| {
72817283
match chan.as_funded_mut() {
72827284
Some(funded_chan) => {
7283-
let new_feerate = commitment_sat_per_1000_weight_for_type(&self.fee_estimator, funded_chan.funding.get_channel_type());
7285+
let new_feerate = selected_commitment_sat_per_1000_weight(
7286+
&self.fee_estimator, funded_chan.funding.get_channel_type(),
7287+
);
72847288
let chan_needs_persist = self.update_channel_fee(chan_id, funded_chan, new_feerate);
72857289
if chan_needs_persist == NotifyOption::DoPersist { should_persist = NotifyOption::DoPersist; }
72867290

0 commit comments

Comments
 (0)