@@ -1877,6 +1877,7 @@ where
1877
1877
holder_commitment_point,
1878
1878
#[cfg(splicing)]
1879
1879
pending_splice: None,
1880
+ quiescent_action: None,
1880
1881
};
1881
1882
let res = funded_channel.initial_commitment_signed_v2(msg, best_block, signer_provider, logger)
1882
1883
.map(|monitor| (Some(monitor), None))
@@ -2443,6 +2444,15 @@ impl PendingSplice {
2443
2444
}
2444
2445
}
2445
2446
2447
+ pub(crate) enum QuiescentAction {
2448
+ // TODO: Make this test-only once we have another variant (as some code requires *a* variant).
2449
+ DoNothing,
2450
+ }
2451
+
2452
+ impl_writeable_tlv_based_enum_upgradable!(QuiescentAction,
2453
+ (99, DoNothing) => {},
2454
+ );
2455
+
2446
2456
/// Wrapper around a [`Transaction`] useful for caching the result of [`Transaction::compute_txid`].
2447
2457
struct ConfirmedTransaction<'a> {
2448
2458
tx: &'a Transaction,
@@ -6084,6 +6094,12 @@ where
6084
6094
/// Info about an in-progress, pending splice (if any), on the pre-splice channel
6085
6095
#[cfg(splicing)]
6086
6096
pending_splice: Option<PendingSplice>,
6097
+
6098
+ /// Once we become quiescent, if we're the initiator, there's some action we'll want to take.
6099
+ /// This keeps track of that action. Note that if we become quiescent and we're not the
6100
+ /// initiator we may be able to merge this action into what the counterparty wanted to do (e.g.
6101
+ /// in the case of splicing).
6102
+ quiescent_action: Option<QuiescentAction>,
6087
6103
}
6088
6104
6089
6105
#[cfg(splicing)]
@@ -11548,7 +11564,7 @@ where
11548
11564
#[cfg(any(test, fuzzing))]
11549
11565
#[rustfmt::skip]
11550
11566
pub fn propose_quiescence<L: Deref>(
11551
- &mut self, logger: &L,
11567
+ &mut self, logger: &L, action: QuiescentAction,
11552
11568
) -> Result<Option<msgs::Stfu>, ChannelError>
11553
11569
where
11554
11570
L::Target: Logger,
@@ -11560,11 +11576,13 @@ where
11560
11576
"Channel is not in a live state to propose quiescence".to_owned()
11561
11577
));
11562
11578
}
11563
- if self.context.channel_state.is_quiescent () {
11564
- return Err(ChannelError::Ignore("Channel is already quiescent ".to_owned()));
11579
+ if self.quiescent_action.is_some () {
11580
+ return Err(ChannelError::Ignore("Channel is already quiescing ".to_owned()));
11565
11581
}
11566
11582
11567
- if self.context.channel_state.is_awaiting_quiescence()
11583
+ self.quiescent_action = Some(action);
11584
+ if self.context.channel_state.is_quiescent()
11585
+ || self.context.channel_state.is_awaiting_quiescence()
11568
11586
|| self.context.channel_state.is_local_stfu_sent()
11569
11587
{
11570
11588
return Ok(None);
@@ -11683,6 +11701,21 @@ where
11683
11701
if !is_holder_quiescence_initiator { " not" } else { "" }
11684
11702
);
11685
11703
11704
+ if is_holder_quiescence_initiator {
11705
+ match self.quiescent_action.take() {
11706
+ None => {
11707
+ debug_assert!(false);
11708
+ return Err(ChannelError::WarnAndDisconnect(
11709
+ "Internal Error: Didn't have anything to do after reaching quiescence".to_owned()
11710
+ ));
11711
+ },
11712
+ Some(QuiescentAction::DoNothing) => {
11713
+ // In quiescence test we want to just hang out here, letting the test manually
11714
+ // leave quiescence.
11715
+ },
11716
+ }
11717
+ }
11718
+
11686
11719
Ok(None)
11687
11720
}
11688
11721
@@ -12048,6 +12081,7 @@ where
12048
12081
holder_commitment_point,
12049
12082
#[cfg(splicing)]
12050
12083
pending_splice: None,
12084
+ quiescent_action: None,
12051
12085
};
12052
12086
12053
12087
let need_channel_ready = channel.check_get_channel_ready(0, logger).is_some()
@@ -12334,6 +12368,7 @@ where
12334
12368
holder_commitment_point,
12335
12369
#[cfg(splicing)]
12336
12370
pending_splice: None,
12371
+ quiescent_action: None,
12337
12372
};
12338
12373
let need_channel_ready = channel.check_get_channel_ready(0, logger).is_some()
12339
12374
|| channel.context.signer_pending_channel_ready;
@@ -13991,6 +14026,7 @@ where
13991
14026
holder_commitment_point,
13992
14027
#[cfg(splicing)]
13993
14028
pending_splice: None,
14029
+ quiescent_action: None,
13994
14030
})
13995
14031
}
13996
14032
}
0 commit comments