Skip to content

Commit a57f46f

Browse files
committed
f - move get_htlc_maximum_msat to FundingScope
1 parent 40d73f5 commit a57f46f

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
@@ -3186,7 +3186,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
31863186

31873187
/// Allowed in any state (including after shutdown), but will return none before TheirInitSent
31883188
pub fn get_holder_htlc_maximum_msat(&self, funding: &FundingScope) -> Option<u64> {
3189-
self.get_htlc_maximum_msat(funding, self.holder_max_htlc_value_in_flight_msat)
3189+
funding.get_htlc_maximum_msat(self.holder_max_htlc_value_in_flight_msat)
31903190
}
31913191

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

31973197
/// Allowed in any state (including after shutdown), but will return none before TheirInitSent
31983198
pub fn get_counterparty_htlc_maximum_msat(&self, funding: &FundingScope) -> Option<u64> {
3199-
self.get_htlc_maximum_msat(funding, self.counterparty_max_htlc_value_in_flight_msat)
3199+
funding.get_htlc_maximum_msat(self.counterparty_max_htlc_value_in_flight_msat)
32003200
}
3201+
}
32013202

3202-
fn get_htlc_maximum_msat(&self, funding: &FundingScope, party_max_htlc_value_in_flight_msat: u64) -> Option<u64> {
3203-
funding.counterparty_selected_channel_reserve_satoshis.map(|counterparty_reserve| {
3204-
let holder_reserve = funding.holder_selected_channel_reserve_satoshis;
3203+
impl FundingScope {
3204+
fn get_htlc_maximum_msat(&self, party_max_htlc_value_in_flight_msat: u64) -> Option<u64> {
3205+
self.counterparty_selected_channel_reserve_satoshis.map(|counterparty_reserve| {
3206+
let holder_reserve = self.holder_selected_channel_reserve_satoshis;
32053207
cmp::min(
3206-
(funding.channel_value_satoshis - counterparty_reserve - holder_reserve) * 1000,
3208+
(self.channel_value_satoshis - counterparty_reserve - holder_reserve) * 1000,
32073209
party_max_htlc_value_in_flight_msat
32083210
)
32093211
})
32103212
}
3213+
}
32113214

3215+
impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
32123216
pub fn get_fee_proportional_millionths(&self) -> u32 {
32133217
self.config.options.forwarding_fee_proportional_millionths
32143218
}

0 commit comments

Comments
 (0)