@@ -1863,6 +1863,7 @@ where
1863
1863
holder_commitment_point,
1864
1864
#[cfg(splicing)]
1865
1865
pending_splice: None,
1866
+ quiescent_action: None,
1866
1867
};
1867
1868
let res = funded_channel.initial_commitment_signed_v2(msg, best_block, signer_provider, logger)
1868
1869
.map(|monitor| (Some(monitor), None))
@@ -2429,6 +2430,15 @@ impl PendingSplice {
2429
2430
}
2430
2431
}
2431
2432
2433
+ pub(crate) enum QuiescentAction {
2434
+ // TODO: Make this test-only once we have another variant (as some code requires *a* variant).
2435
+ DoNothing,
2436
+ }
2437
+
2438
+ impl_writeable_tlv_based_enum_upgradable!(QuiescentAction,
2439
+ (99, DoNothing) => {},
2440
+ );
2441
+
2432
2442
/// Wrapper around a [`Transaction`] useful for caching the result of [`Transaction::compute_txid`].
2433
2443
struct ConfirmedTransaction<'a> {
2434
2444
tx: &'a Transaction,
@@ -6050,6 +6060,12 @@ where
6050
6060
/// Info about an in-progress, pending splice (if any), on the pre-splice channel
6051
6061
#[cfg(splicing)]
6052
6062
pending_splice: Option<PendingSplice>,
6063
+
6064
+ /// Once we become quiescent, if we're the initiator, there's some action we'll want to take.
6065
+ /// This keeps track of that action. Note that if we become quiescent and we're not the
6066
+ /// initiator we may be able to merge this action into what the counterparty wanted to do (e.g.
6067
+ /// in the case of splicing).
6068
+ quiescent_action: Option<QuiescentAction>,
6053
6069
}
6054
6070
6055
6071
#[cfg(splicing)]
@@ -11529,7 +11545,7 @@ where
11529
11545
#[cfg(any(test, fuzzing))]
11530
11546
#[rustfmt::skip]
11531
11547
pub fn propose_quiescence<L: Deref>(
11532
- &mut self, logger: &L,
11548
+ &mut self, logger: &L, action: QuiescentAction,
11533
11549
) -> Result<Option<msgs::Stfu>, ChannelError>
11534
11550
where
11535
11551
L::Target: Logger,
@@ -11541,11 +11557,13 @@ where
11541
11557
"Channel is not in a live state to propose quiescence".to_owned()
11542
11558
));
11543
11559
}
11544
- if self.context.channel_state.is_quiescent () {
11545
- return Err(ChannelError::Ignore("Channel is already quiescent ".to_owned()));
11560
+ if self.quiescent_action.is_some () {
11561
+ return Err(ChannelError::Ignore("Channel is already quiescing ".to_owned()));
11546
11562
}
11547
11563
11548
- if self.context.channel_state.is_awaiting_quiescence()
11564
+ self.quiescent_action = Some(action);
11565
+ if self.context.channel_state.is_quiescent()
11566
+ || self.context.channel_state.is_awaiting_quiescence()
11549
11567
|| self.context.channel_state.is_local_stfu_sent()
11550
11568
{
11551
11569
return Ok(None);
@@ -11664,6 +11682,21 @@ where
11664
11682
if !is_holder_quiescence_initiator { " not" } else { "" }
11665
11683
);
11666
11684
11685
+ if is_holder_quiescence_initiator {
11686
+ match self.quiescent_action.take() {
11687
+ None => {
11688
+ debug_assert!(false);
11689
+ return Err(ChannelError::WarnAndDisconnect(
11690
+ "Internal Error: Didn't have anything to do after reaching quiescence".to_owned()
11691
+ ));
11692
+ },
11693
+ Some(QuiescentAction::DoNothing) => {
11694
+ // In quiescence test we want to just hang out here, letting the test manually
11695
+ // leave quiescence.
11696
+ },
11697
+ }
11698
+ }
11699
+
11667
11700
Ok(None)
11668
11701
}
11669
11702
@@ -12029,6 +12062,7 @@ where
12029
12062
holder_commitment_point,
12030
12063
#[cfg(splicing)]
12031
12064
pending_splice: None,
12065
+ quiescent_action: None,
12032
12066
};
12033
12067
12034
12068
let need_channel_ready = channel.check_get_channel_ready(0, logger).is_some()
@@ -12315,6 +12349,7 @@ where
12315
12349
holder_commitment_point,
12316
12350
#[cfg(splicing)]
12317
12351
pending_splice: None,
12352
+ quiescent_action: None,
12318
12353
};
12319
12354
let need_channel_ready = channel.check_get_channel_ready(0, logger).is_some()
12320
12355
|| channel.context.signer_pending_channel_ready;
@@ -13974,6 +14009,7 @@ where
13974
14009
holder_commitment_point,
13975
14010
#[cfg(splicing)]
13976
14011
pending_splice: None,
14012
+ quiescent_action: None,
13977
14013
})
13978
14014
}
13979
14015
}
0 commit comments