Skip to content

Commit 2655f83

Browse files
committed
fix Get rid of swap_out_dual_funding_context_inputs
1 parent 0f8acd3 commit 2655f83

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

lightning/src/ln/channel.rs

+11-16
Original file line numberDiff line numberDiff line change
@@ -2458,17 +2458,11 @@ impl<SP: Deref> FundingTxConstructorV2<SP> for FundedChannel<SP> where SP::Targe
24582458
).flatten().ok_or("Not re-funding")
24592459
}
24602460

2461-
fn swap_out_dual_funding_context_inputs(&mut self, funding_inputs: &mut Vec<(TxIn, TransactionU16LenLimited)>) -> Result<(), &'static str> {
2462-
if let Some(pending_splice) = &mut self.pending_splice {
2463-
if let Some(refunding) = &mut pending_splice.refunding_scope {
2464-
mem::swap(&mut refunding.pending_dual_funding_context.our_funding_inputs, funding_inputs);
2465-
Ok(())
2466-
} else {
2467-
Err("Not re-funding")
2468-
}
2469-
} else {
2470-
Err("Not re-funding")
2471-
}
2461+
#[inline]
2462+
fn dual_funding_context_mut(&mut self) -> Result<&mut DualFundingChannelContext, &'static str> {
2463+
self.pending_splice.as_mut().map(|splice|
2464+
splice.refunding_scope.as_mut().map(|refunding| &mut refunding.pending_dual_funding_context)
2465+
).flatten().ok_or("Not re-funding")
24722466
}
24732467

24742468
#[inline]
@@ -2509,7 +2503,7 @@ pub(super) trait FundingTxConstructorV2<SP: Deref>: ChannelContextProvider<SP> w
25092503
fn pending_funding_mut(&mut self) -> Result<&mut FundingScope, &'static str>;
25102504
fn pending_funding_and_context_mut(&mut self) -> Result<(&FundingScope, &mut ChannelContext<SP>), &'static str>;
25112505
fn dual_funding_context(&self) -> Result<&DualFundingChannelContext, &'static str>;
2512-
fn swap_out_dual_funding_context_inputs(&mut self, funding_inputs: &mut Vec<(TxIn, TransactionU16LenLimited)>) -> Result<(), &'static str>;
2506+
fn dual_funding_context_mut(&mut self) -> Result<&mut DualFundingChannelContext, &'static str>;
25132507
fn unfunded_context(&self) -> Result<&UnfundedChannelContext, &'static str>;
25142508
fn interactive_tx_constructor(&self) -> Result<Option<&InteractiveTxConstructor>, &'static str>;
25152509
fn interactive_tx_constructor_mut(&mut self) -> Result<&mut Option<InteractiveTxConstructor>, &'static str>;
@@ -2536,8 +2530,9 @@ pub(super) trait FundingTxConstructorV2<SP: Deref>: ChannelContextProvider<SP> w
25362530
debug_assert!(self.interactive_tx_constructor().unwrap_or(None).is_none());
25372531

25382532
let mut funding_inputs = Vec::new();
2539-
self.swap_out_dual_funding_context_inputs(&mut funding_inputs)
2533+
let dual_funding_context_mut = self.dual_funding_context_mut()
25402534
.map_err(|e| AbortReason::InternalError(e))?;
2535+
mem::swap(&mut dual_funding_context_mut.our_funding_inputs, &mut funding_inputs);
25412536

25422537
if let Some(prev_funding_input) = prev_funding_input {
25432538
funding_inputs.push(prev_funding_input);
@@ -2839,9 +2834,9 @@ impl<SP: Deref> FundingTxConstructorV2<SP> for PendingV2Channel<SP> where SP::Ta
28392834
Ok(&self.dual_funding_context)
28402835
}
28412836

2842-
fn swap_out_dual_funding_context_inputs(&mut self, funding_inputs: &mut Vec<(TxIn, TransactionU16LenLimited)>) -> Result<(), &'static str> {
2843-
mem::swap(&mut self.dual_funding_context.our_funding_inputs, funding_inputs);
2844-
Ok(())
2837+
#[inline]
2838+
fn dual_funding_context_mut(&mut self) -> Result<&mut DualFundingChannelContext, &'static str> {
2839+
Ok(&mut self.dual_funding_context)
28452840
}
28462841

28472842
#[inline]

0 commit comments

Comments
 (0)