Skip to content

Commit 2e84b26

Browse files
Rename pending_monitor_events to _legacy
This field will be deprecated in upcoming commits when we start persisting MonitorEvent ids alongside the MonitorEvents.
1 parent da3632b commit 2e84b26

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

lightning/src/chain/channelmonitor.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,7 +1736,7 @@ pub(crate) fn write_chanmon_internal<Signer: EcdsaChannelSigner, W: Writer>(
17361736
None
17371737
}
17381738
});
1739-
let pending_monitor_events = Iterable(
1739+
let pending_monitor_events_legacy = Iterable(
17401740
channel_monitor.pending_monitor_events.iter().chain(holder_force_closed_compat.as_ref()),
17411741
);
17421742

@@ -1747,7 +1747,7 @@ pub(crate) fn write_chanmon_internal<Signer: EcdsaChannelSigner, W: Writer>(
17471747
(1, channel_monitor.funding_spend_confirmed, option),
17481748
(2, persistent_events_enabled, option),
17491749
(3, channel_monitor.htlcs_resolved_on_chain, required_vec),
1750-
(5, pending_monitor_events, required), // Equivalent to required_vec because Iterable also writes as WithoutLength
1750+
(5, pending_monitor_events_legacy, required), // Equivalent to required_vec because Iterable also writes as WithoutLength
17511751
(7, channel_monitor.funding_spend_seen, required),
17521752
(9, channel_monitor.counterparty_node_id, required),
17531753
(11, channel_monitor.confirmed_commitment_tx_counterparty_output, option),
@@ -6645,16 +6645,16 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
66456645
}
66466646
}
66476647

6648-
let pending_monitor_events_len: u64 = Readable::read(reader)?;
6649-
let mut pending_monitor_events = Some(
6650-
Vec::with_capacity(cmp::min(pending_monitor_events_len as usize, MAX_ALLOC_SIZE / (32 + 8*3))));
6651-
for _ in 0..pending_monitor_events_len {
6648+
let pending_monitor_events_legacy_len: u64 = Readable::read(reader)?;
6649+
let mut pending_monitor_events_legacy = Some(
6650+
Vec::with_capacity(cmp::min(pending_monitor_events_legacy_len as usize, MAX_ALLOC_SIZE / (32 + 8*3))));
6651+
for _ in 0..pending_monitor_events_legacy_len {
66526652
let ev = match <u8 as Readable>::read(reader)? {
66536653
0 => MonitorEvent::HTLCEvent(Readable::read(reader)?),
66546654
1 => MonitorEvent::HolderForceClosed(outpoint),
66556655
_ => return Err(DecodeError::InvalidValue)
66566656
};
6657-
pending_monitor_events.as_mut().unwrap().push(ev);
6657+
pending_monitor_events_legacy.as_mut().unwrap().push(ev);
66586658
}
66596659

66606660
let pending_events_len: u64 = Readable::read(reader)?;
@@ -6721,7 +6721,7 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
67216721
(1, funding_spend_confirmed, option),
67226722
(2, persistent_events_enabled, option),
67236723
(3, htlcs_resolved_on_chain, optional_vec),
6724-
(5, pending_monitor_events, optional_vec),
6724+
(5, pending_monitor_events_legacy, optional_vec),
67256725
(7, funding_spend_seen, option),
67266726
(9, counterparty_node_id, option),
67276727
(11, confirmed_commitment_tx_counterparty_output, option),
@@ -6774,11 +6774,11 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
67746774

67756775
// `HolderForceClosedWithInfo` replaced `HolderForceClosed` in v0.0.122. If we have both
67766776
// events, we can remove the `HolderForceClosed` event and just keep the `HolderForceClosedWithInfo`.
6777-
if let Some(ref mut pending_monitor_events) = pending_monitor_events {
6778-
if pending_monitor_events.iter().any(|e| matches!(e, MonitorEvent::HolderForceClosed(_))) &&
6779-
pending_monitor_events.iter().any(|e| matches!(e, MonitorEvent::HolderForceClosedWithInfo { .. }))
6777+
if let Some(ref mut evs) = pending_monitor_events_legacy {
6778+
if evs.iter().any(|e| matches!(e, MonitorEvent::HolderForceClosed(_))) &&
6779+
evs.iter().any(|e| matches!(e, MonitorEvent::HolderForceClosedWithInfo { .. }))
67806780
{
6781-
pending_monitor_events.retain(|e| !matches!(e, MonitorEvent::HolderForceClosed(_)));
6781+
evs.retain(|e| !matches!(e, MonitorEvent::HolderForceClosed(_)));
67826782
}
67836783
}
67846784

@@ -6899,7 +6899,7 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
68996899
current_holder_commitment_number,
69006900

69016901
payment_preimages,
6902-
pending_monitor_events: pending_monitor_events.unwrap(),
6902+
pending_monitor_events: pending_monitor_events_legacy.unwrap(),
69036903
persistent_events_enabled: persistent_events_enabled.is_some(),
69046904
pending_events,
69056905
is_processing_pending_events: false,

0 commit comments

Comments
 (0)