Skip to content

Commit 5a65366

Browse files
committed
f - move get_htlc_maximum_msat to FundingScope
1 parent 8f6f0a9 commit 5a65366

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lightning/src/ln/channel.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3165,7 +3165,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
31653165

31663166
/// Allowed in any state (including after shutdown), but will return none before TheirInitSent
31673167
pub fn get_holder_htlc_maximum_msat(&self, funding: &FundingScope) -> Option<u64> {
3168-
self.get_htlc_maximum_msat(funding, self.holder_max_htlc_value_in_flight_msat)
3168+
funding.get_htlc_maximum_msat(self.holder_max_htlc_value_in_flight_msat)
31693169
}
31703170

31713171
/// Allowed in any state (including after shutdown)
@@ -3175,19 +3175,23 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
31753175

31763176
/// Allowed in any state (including after shutdown), but will return none before TheirInitSent
31773177
pub fn get_counterparty_htlc_maximum_msat(&self, funding: &FundingScope) -> Option<u64> {
3178-
self.get_htlc_maximum_msat(funding, self.counterparty_max_htlc_value_in_flight_msat)
3178+
funding.get_htlc_maximum_msat(self.counterparty_max_htlc_value_in_flight_msat)
31793179
}
3180+
}
31803181

3181-
fn get_htlc_maximum_msat(&self, funding: &FundingScope, party_max_htlc_value_in_flight_msat: u64) -> Option<u64> {
3182-
funding.counterparty_selected_channel_reserve_satoshis.map(|counterparty_reserve| {
3183-
let holder_reserve = funding.holder_selected_channel_reserve_satoshis;
3182+
impl FundingScope {
3183+
fn get_htlc_maximum_msat(&self, party_max_htlc_value_in_flight_msat: u64) -> Option<u64> {
3184+
self.counterparty_selected_channel_reserve_satoshis.map(|counterparty_reserve| {
3185+
let holder_reserve = self.holder_selected_channel_reserve_satoshis;
31843186
cmp::min(
3185-
(funding.channel_value_satoshis - counterparty_reserve - holder_reserve) * 1000,
3187+
(self.channel_value_satoshis - counterparty_reserve - holder_reserve) * 1000,
31863188
party_max_htlc_value_in_flight_msat
31873189
)
31883190
})
31893191
}
3192+
}
31903193

3194+
impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
31913195
pub fn get_fee_proportional_millionths(&self) -> u32 {
31923196
self.config.options.forwarding_fee_proportional_millionths
31933197
}

0 commit comments

Comments
 (0)