Skip to content

Commit e1a70a6

Browse files
committed
Allow holding ChannelMonitorUpdates until later, completing one
In the coming commits, we need to delay `ChannelMonitorUpdate`s until future actions (specifically `Event` handling). However, because we should only notify users once of a given `ChannelMonitorUpdate` and they must be provided in-order, we need to track which ones have or have not been given to users and, once updating resumes, fly the ones that haven't already made it to users. To do this we simply add a `bool` in the `ChannelMonitorUpdate` set stored in the `Channel` which indicates if an update flew and decline to provide new updates back to the `ChannelManager` if any updates have their flown bit unset. Further, because we'll now by releasing `ChannelMonitorUpdate`s which were already stored in the pending list, we now need to support getting a `Completed` result for a monitor which isn't the only pending monitor (or even out of order), thus we also rewrite the way monitor updates are marked completed.
1 parent 049f3b6 commit e1a70a6

File tree

4 files changed

+150
-62
lines changed

4 files changed

+150
-62
lines changed

lightning/src/ln/chanmon_update_fail_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ fn test_monitor_and_persister_update_fail() {
144144
let mut node_0_per_peer_lock;
145145
let mut node_0_peer_state_lock;
146146
let mut channel = get_channel_ref!(nodes[0], nodes[1], node_0_per_peer_lock, node_0_peer_state_lock, chan.2);
147-
if let Ok(update) = channel.commitment_signed(&updates.commitment_signed, &node_cfgs[0].logger) {
147+
if let Ok(Some(update)) = channel.commitment_signed(&updates.commitment_signed, &node_cfgs[0].logger) {
148148
// Check that even though the persister is returning a InProgress,
149149
// because the update is bogus, ultimately the error that's returned
150150
// should be a PermanentFailure.

lightning/src/ln/channel.rs

Lines changed: 131 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,17 @@ pub(crate) const MIN_AFFORDABLE_HTLC_COUNT: usize = 4;
479479
/// * `EXPIRE_PREV_CONFIG_TICKS` = convergence_delay / tick_interval
480480
pub(crate) const EXPIRE_PREV_CONFIG_TICKS: usize = 5;
481481

482+
struct PendingChannelMonitorUpdate {
483+
update: ChannelMonitorUpdate,
484+
/// In some cases we need to delay letting the [`ChannelMonitorUpdate`] fly until after an
485+
/// `Event` is processed by the user. This bool indicates the [`ChannelMonitorUpdate`] has
486+
/// flown and we're waiting to hear back, otherwise the update is waiting on some external
487+
/// event and the [`ChannelManager`] will update us when we're ready.
488+
///
489+
/// [`ChannelManager`]: super::channelmanager::ChannelManager
490+
flown: bool,
491+
}
492+
482493
// TODO: We should refactor this to be an Inbound/OutboundChannel until initial setup handshaking
483494
// has been completed, and then turn into a Channel to get compiler-time enforcement of things like
484495
// calling channel_id() before we're set up or things like get_outbound_funding_signed on an
@@ -740,7 +751,7 @@ pub(super) struct Channel<Signer: ChannelSigner> {
740751
/// If we then persist the [`channelmanager::ChannelManager`] and crash before the persistence
741752
/// completes we still need to be able to complete the persistence. Thus, we have to keep a
742753
/// copy of the [`ChannelMonitorUpdate`] here until it is complete.
743-
pending_monitor_updates: Vec<ChannelMonitorUpdate>,
754+
pending_monitor_updates: Vec<PendingChannelMonitorUpdate>,
744755
}
745756

746757
#[cfg(any(test, fuzzing))]
@@ -1967,28 +1978,46 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
19671978
}
19681979

19691980
pub fn get_update_fulfill_htlc_and_commit<L: Deref>(&mut self, htlc_id: u64, payment_preimage: PaymentPreimage, logger: &L) -> UpdateFulfillCommitFetch where L::Target: Logger {
1981+
let fly_cs_monitor = self.pending_monitor_updates.iter().all(|upd| upd.flown);
19701982
match self.get_update_fulfill_htlc(htlc_id, payment_preimage, logger) {
1971-
UpdateFulfillFetch::NewClaim { mut monitor_update, htlc_value_msat, msg: Some(_) } => {
1972-
let mut additional_update = self.build_commitment_no_status_check(logger);
1973-
// build_commitment_no_status_check may bump latest_monitor_id but we want them to be
1974-
// strictly increasing by one, so decrement it here.
1975-
self.latest_monitor_update_id = monitor_update.update_id;
1976-
monitor_update.updates.append(&mut additional_update.updates);
1977-
self.monitor_updating_paused(false, true, false, Vec::new(), Vec::new(), Vec::new());
1978-
self.pending_monitor_updates.push(monitor_update);
1983+
UpdateFulfillFetch::NewClaim { mut monitor_update, htlc_value_msat, msg } => {
1984+
// Even if we aren't supposed to let new monitor updates with commitment state
1985+
// updates fly, we still need to push the preimage ChannelMonitorUpdateStep no
1986+
// matter what. Sadly, to push a new monitor update which flies before others
1987+
// already queued, we have to insert it into the pending queue and update the
1988+
// update_ids of all the following monitors.
1989+
let flown_monitor_pos = if fly_cs_monitor && msg.is_some() {
1990+
// build_commitment_no_status_check may bump latest_monitor_id but we want them to be
1991+
// strictly increasing by one, so decrement it here.
1992+
let mut additional_update = self.build_commitment_no_status_check(logger);
1993+
self.latest_monitor_update_id = monitor_update.update_id;
1994+
monitor_update.updates.append(&mut additional_update.updates);
1995+
self.monitor_updating_paused(false, true, false, Vec::new(), Vec::new(), Vec::new());
1996+
self.pending_monitor_updates.push(PendingChannelMonitorUpdate {
1997+
update: monitor_update, flown: true,
1998+
});
1999+
self.pending_monitor_updates.len() - 1
2000+
} else {
2001+
let insert_pos = self.pending_monitor_updates.iter().position(|upd| !upd.flown)
2002+
.unwrap_or(self.pending_monitor_updates.len());
2003+
self.pending_monitor_updates.insert(insert_pos, PendingChannelMonitorUpdate {
2004+
update: monitor_update, flown: true,
2005+
});
2006+
if msg.is_some() {
2007+
let update = self.build_commitment_no_status_check(logger);
2008+
self.pending_monitor_updates.push(PendingChannelMonitorUpdate {
2009+
update, flown: false,
2010+
});
2011+
}
2012+
insert_pos
2013+
};
2014+
self.monitor_updating_paused(false, msg.is_some(), false, Vec::new(), Vec::new(), Vec::new());
19792015
UpdateFulfillCommitFetch::NewClaim {
1980-
monitor_update: self.pending_monitor_updates.last().unwrap(),
2016+
monitor_update: &self.pending_monitor_updates.get(flown_monitor_pos)
2017+
.expect("We just pushed the monitor update").update,
19812018
htlc_value_msat,
19822019
}
19832020
},
1984-
UpdateFulfillFetch::NewClaim { monitor_update, htlc_value_msat, msg: None } => {
1985-
self.monitor_updating_paused(false, false, false, Vec::new(), Vec::new(), Vec::new());
1986-
self.pending_monitor_updates.push(monitor_update);
1987-
UpdateFulfillCommitFetch::NewClaim {
1988-
monitor_update: self.pending_monitor_updates.last().unwrap(),
1989-
htlc_value_msat,
1990-
}
1991-
}
19922021
UpdateFulfillFetch::DuplicateClaim {} => UpdateFulfillCommitFetch::DuplicateClaim {},
19932022
}
19942023
}
@@ -3054,7 +3083,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
30543083
Ok(())
30553084
}
30563085

3057-
pub fn commitment_signed<L: Deref>(&mut self, msg: &msgs::CommitmentSigned, logger: &L) -> Result<&ChannelMonitorUpdate, ChannelError>
3086+
pub fn commitment_signed<L: Deref>(&mut self, msg: &msgs::CommitmentSigned, logger: &L) -> Result<Option<&ChannelMonitorUpdate>, ChannelError>
30583087
where L::Target: Logger
30593088
{
30603089
if (self.channel_state & (ChannelState::ChannelReady as u32)) != (ChannelState::ChannelReady as u32) {
@@ -3230,8 +3259,11 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
32303259
}
32313260
log_debug!(logger, "Received valid commitment_signed from peer in channel {}, updated HTLC state but awaiting a monitor update resolution to reply.",
32323261
log_bytes!(self.channel_id));
3233-
self.pending_monitor_updates.push(monitor_update);
3234-
return Ok(self.pending_monitor_updates.last().unwrap());
3262+
let fly_monitor = self.pending_monitor_updates.iter().all(|upd| upd.flown);
3263+
self.pending_monitor_updates.push(PendingChannelMonitorUpdate {
3264+
update: monitor_update, flown: fly_monitor
3265+
});
3266+
return Ok(if fly_monitor { self.pending_monitor_updates.last().map(|upd| &upd.update) } else { None });
32353267
}
32363268

32373269
let need_commitment_signed = if need_commitment && (self.channel_state & (ChannelState::AwaitingRemoteRevoke as u32)) == 0 {
@@ -3248,9 +3280,12 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
32483280

32493281
log_debug!(logger, "Received valid commitment_signed from peer in channel {}, updating HTLC state and responding with{} a revoke_and_ack.",
32503282
log_bytes!(self.channel_id()), if need_commitment_signed { " our own commitment_signed and" } else { "" });
3251-
self.pending_monitor_updates.push(monitor_update);
3283+
let fly_monitor = self.pending_monitor_updates.iter().all(|upd| upd.flown);
3284+
self.pending_monitor_updates.push(PendingChannelMonitorUpdate {
3285+
update: monitor_update, flown: fly_monitor,
3286+
});
32523287
self.monitor_updating_paused(true, need_commitment_signed, false, Vec::new(), Vec::new(), Vec::new());
3253-
return Ok(self.pending_monitor_updates.last().unwrap());
3288+
return Ok(if fly_monitor { self.pending_monitor_updates.last().map(|upd| &upd.update) } else { None });
32543289
}
32553290

32563291
/// Public version of the below, checking relevant preconditions first.
@@ -3365,8 +3400,12 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
33653400
update_add_htlcs.len(), update_fulfill_htlcs.len(), update_fail_htlcs.len());
33663401

33673402
self.monitor_updating_paused(false, true, false, Vec::new(), Vec::new(), Vec::new());
3368-
self.pending_monitor_updates.push(monitor_update);
3369-
(Some(self.pending_monitor_updates.last().unwrap()), htlcs_to_fail)
3403+
let fly_monitor = self.pending_monitor_updates.iter().all(|upd| upd.flown);
3404+
self.pending_monitor_updates.push(PendingChannelMonitorUpdate {
3405+
update: monitor_update, flown: fly_monitor,
3406+
});
3407+
(if fly_monitor { self.pending_monitor_updates.last().map(|upd| &upd.update) } else { None },
3408+
htlcs_to_fail)
33703409
} else {
33713410
(None, Vec::new())
33723411
}
@@ -3377,7 +3416,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
33773416
/// waiting on this revoke_and_ack. The generation of this new commitment_signed may also fail,
33783417
/// generating an appropriate error *after* the channel state has been updated based on the
33793418
/// revoke_and_ack message.
3380-
pub fn revoke_and_ack<L: Deref>(&mut self, msg: &msgs::RevokeAndACK, logger: &L) -> Result<(Vec<(HTLCSource, PaymentHash)>, &ChannelMonitorUpdate), ChannelError>
3419+
pub fn revoke_and_ack<L: Deref>(&mut self, msg: &msgs::RevokeAndACK, logger: &L) -> Result<(Vec<(HTLCSource, PaymentHash)>, Option<&ChannelMonitorUpdate>), ChannelError>
33813420
where L::Target: Logger,
33823421
{
33833422
if (self.channel_state & (ChannelState::ChannelReady as u32)) != (ChannelState::ChannelReady as u32) {
@@ -3574,21 +3613,29 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
35743613
self.monitor_pending_failures.append(&mut revoked_htlcs);
35753614
self.monitor_pending_finalized_fulfills.append(&mut finalized_claimed_htlcs);
35763615
log_debug!(logger, "Received a valid revoke_and_ack for channel {} but awaiting a monitor update resolution to reply.", log_bytes!(self.channel_id()));
3577-
self.pending_monitor_updates.push(monitor_update);
3578-
return Ok((Vec::new(), self.pending_monitor_updates.last().unwrap()));
3616+
let fly_monitor = self.pending_monitor_updates.iter().all(|upd| upd.flown);
3617+
self.pending_monitor_updates.push(PendingChannelMonitorUpdate {
3618+
update: monitor_update, flown: fly_monitor,
3619+
});
3620+
return Ok((Vec::new(),
3621+
if fly_monitor { self.pending_monitor_updates.last().map(|upd| &upd.update) } else { None }));
35793622
}
35803623

35813624
match self.free_holding_cell_htlcs(logger) {
35823625
(Some(_), htlcs_to_fail) => {
3583-
let mut additional_update = self.pending_monitor_updates.pop().unwrap();
3626+
let mut additional_update = self.pending_monitor_updates.pop().unwrap().update;
35843627
// free_holding_cell_htlcs may bump latest_monitor_id multiple times but we want them to be
35853628
// strictly increasing by one, so decrement it here.
35863629
self.latest_monitor_update_id = monitor_update.update_id;
35873630
monitor_update.updates.append(&mut additional_update.updates);
35883631

35893632
self.monitor_updating_paused(false, true, false, to_forward_infos, revoked_htlcs, finalized_claimed_htlcs);
3590-
self.pending_monitor_updates.push(monitor_update);
3591-
Ok((htlcs_to_fail, self.pending_monitor_updates.last().unwrap()))
3633+
let fly_monitor = self.pending_monitor_updates.iter().all(|upd| upd.flown);
3634+
self.pending_monitor_updates.push(PendingChannelMonitorUpdate {
3635+
update: monitor_update, flown: fly_monitor,
3636+
});
3637+
Ok((htlcs_to_fail,
3638+
if fly_monitor { self.pending_monitor_updates.last().map(|upd| &upd.update) } else { None }))
35923639
},
35933640
(None, htlcs_to_fail) => {
35943641
if require_commitment {
@@ -3602,13 +3649,21 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
36023649
log_debug!(logger, "Received a valid revoke_and_ack for channel {}. Responding with a commitment update with {} HTLCs failed.",
36033650
log_bytes!(self.channel_id()), update_fail_htlcs.len() + update_fail_malformed_htlcs.len());
36043651
self.monitor_updating_paused(false, true, false, to_forward_infos, revoked_htlcs, finalized_claimed_htlcs);
3605-
self.pending_monitor_updates.push(monitor_update);
3606-
Ok((htlcs_to_fail, self.pending_monitor_updates.last().unwrap()))
3652+
let fly_monitor = self.pending_monitor_updates.iter().all(|upd| upd.flown);
3653+
self.pending_monitor_updates.push(PendingChannelMonitorUpdate {
3654+
update: monitor_update, flown: fly_monitor,
3655+
});
3656+
Ok((htlcs_to_fail,
3657+
if fly_monitor { self.pending_monitor_updates.last().map(|upd| &upd.update) } else { None }))
36073658
} else {
36083659
log_debug!(logger, "Received a valid revoke_and_ack for channel {} with no reply necessary.", log_bytes!(self.channel_id()));
36093660
self.monitor_updating_paused(false, false, false, to_forward_infos, revoked_htlcs, finalized_claimed_htlcs);
3610-
self.pending_monitor_updates.push(monitor_update);
3611-
Ok((htlcs_to_fail, self.pending_monitor_updates.last().unwrap()))
3661+
let fly_monitor = self.pending_monitor_updates.iter().all(|upd| upd.flown);
3662+
self.pending_monitor_updates.push(PendingChannelMonitorUpdate {
3663+
update: monitor_update, flown: fly_monitor,
3664+
});
3665+
Ok((htlcs_to_fail,
3666+
if fly_monitor { self.pending_monitor_updates.last().map(|upd| &upd.update) } else { None }))
36123667
}
36133668
}
36143669
}
@@ -3797,7 +3852,12 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
37973852
{
37983853
assert_eq!(self.channel_state & ChannelState::MonitorUpdateInProgress as u32, ChannelState::MonitorUpdateInProgress as u32);
37993854
self.channel_state &= !(ChannelState::MonitorUpdateInProgress as u32);
3800-
self.pending_monitor_updates.clear();
3855+
let mut found_unflown = false;
3856+
self.pending_monitor_updates.retain(|upd| {
3857+
if found_unflown { debug_assert!(!upd.flown, "No mons may fly after one is paused"); }
3858+
if !upd.flown { found_unflown = true; }
3859+
!upd.flown
3860+
});
38013861

38023862
// If we're past (or at) the FundingSent stage on an outbound channel, try to
38033863
// (re-)broadcast the funding transaction as we may have declined to broadcast it when we
@@ -4338,8 +4398,11 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
43384398
}],
43394399
};
43404400
self.monitor_updating_paused(false, false, false, Vec::new(), Vec::new(), Vec::new());
4341-
self.pending_monitor_updates.push(monitor_update);
4342-
Some(self.pending_monitor_updates.last().unwrap())
4401+
let fly_monitor = self.pending_monitor_updates.iter().all(|upd| upd.flown);
4402+
self.pending_monitor_updates.push(PendingChannelMonitorUpdate {
4403+
update: monitor_update, flown: fly_monitor,
4404+
});
4405+
if fly_monitor { self.pending_monitor_updates.last().map(|upd| &upd.update) } else { None }
43434406
} else { None };
43444407
let shutdown = if send_shutdown {
43454408
Some(msgs::Shutdown {
@@ -4889,8 +4952,25 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
48894952
(self.channel_state & ChannelState::MonitorUpdateInProgress as u32) != 0
48904953
}
48914954

4892-
pub fn get_next_monitor_update(&self) -> Option<&ChannelMonitorUpdate> {
4893-
self.pending_monitor_updates.first()
4955+
/// Returns the next unflown monitor update, if one exists, and a bool which indicates a
4956+
/// further unflown monitor update exists after the next.
4957+
pub fn fly_next_unflown_monitor_update(&mut self) -> Option<(&ChannelMonitorUpdate, bool)> {
4958+
for i in 0..self.pending_monitor_updates.len() {
4959+
if !self.pending_monitor_updates[i].flown {
4960+
self.pending_monitor_updates[i].flown = true;
4961+
return Some((&self.pending_monitor_updates[i].update,
4962+
self.pending_monitor_updates.len() > i + 1));
4963+
}
4964+
}
4965+
None
4966+
}
4967+
4968+
pub fn no_monitor_updates_pending(&self) -> bool {
4969+
self.pending_monitor_updates.is_empty()
4970+
}
4971+
4972+
pub fn complete_one_mon_update(&mut self, update_id: u64) {
4973+
self.pending_monitor_updates.retain(|upd| upd.update.update_id != update_id);
48944974
}
48954975

48964976
/// Returns true if funding_created was sent/received.
@@ -5930,8 +6010,12 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
59306010
Some(_) => {
59316011
let monitor_update = self.build_commitment_no_status_check(logger);
59326012
self.monitor_updating_paused(false, true, false, Vec::new(), Vec::new(), Vec::new());
5933-
self.pending_monitor_updates.push(monitor_update);
5934-
Ok(Some(self.pending_monitor_updates.last().unwrap()))
6013+
6014+
let fly_monitor = self.pending_monitor_updates.iter().all(|upd| upd.flown);
6015+
self.pending_monitor_updates.push(PendingChannelMonitorUpdate {
6016+
update: monitor_update, flown: fly_monitor,
6017+
});
6018+
Ok(if fly_monitor { self.pending_monitor_updates.last().map(|upd| &upd.update) } else { None })
59356019
},
59366020
None => Ok(None)
59376021
}
@@ -6020,8 +6104,11 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
60206104
}],
60216105
};
60226106
self.monitor_updating_paused(false, false, false, Vec::new(), Vec::new(), Vec::new());
6023-
self.pending_monitor_updates.push(monitor_update);
6024-
Some(self.pending_monitor_updates.last().unwrap())
6107+
let fly_monitor = self.pending_monitor_updates.iter().all(|upd| upd.flown);
6108+
self.pending_monitor_updates.push(PendingChannelMonitorUpdate {
6109+
update: monitor_update, flown: fly_monitor,
6110+
});
6111+
if fly_monitor { self.pending_monitor_updates.last().map(|upd| &upd.update) } else { None }
60256112
} else { None };
60266113
let shutdown = msgs::Shutdown {
60276114
channel_id: self.channel_id,

lightning/src/ln/channelmanager.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,11 +1619,8 @@ macro_rules! handle_new_monitor_update {
16191619
res
16201620
},
16211621
ChannelMonitorUpdateStatus::Completed => {
1622-
if ($update_id == 0 || $chan.get_next_monitor_update()
1623-
.expect("We can't be processing a monitor update if it isn't queued")
1624-
.update_id == $update_id) &&
1625-
$chan.get_latest_monitor_update_id() == $update_id
1626-
{
1622+
$chan.complete_one_mon_update($update_id);
1623+
if $chan.no_monitor_updates_pending() {
16271624
handle_monitor_update_completion!($self, $update_id, $peer_state_lock, $peer_state, $per_peer_state_lock, $chan);
16281625
}
16291626
Ok(())
@@ -4938,11 +4935,13 @@ where
49384935
match peer_state.channel_by_id.entry(msg.channel_id) {
49394936
hash_map::Entry::Occupied(mut chan) => {
49404937
let funding_txo = chan.get().get_funding_txo();
4941-
let monitor_update = try_chan_entry!(self, chan.get_mut().commitment_signed(&msg, &self.logger), chan);
4942-
let update_res = self.chain_monitor.update_channel(funding_txo.unwrap(), monitor_update);
4943-
let update_id = monitor_update.update_id;
4944-
handle_new_monitor_update!(self, update_res, update_id, peer_state_lock,
4945-
peer_state, per_peer_state, chan)
4938+
let monitor_update_opt = try_chan_entry!(self, chan.get_mut().commitment_signed(&msg, &self.logger), chan);
4939+
if let Some(monitor_update) = monitor_update_opt {
4940+
let update_res = self.chain_monitor.update_channel(funding_txo.unwrap(), monitor_update);
4941+
let update_id = monitor_update.update_id;
4942+
handle_new_monitor_update!(self, update_res, update_id, peer_state_lock,
4943+
peer_state, per_peer_state, chan)
4944+
} else { Ok(()) }
49464945
},
49474946
hash_map::Entry::Vacant(_) => return Err(MsgHandleErrInternal::send_err_msg_no_close(format!("Got a message for a channel from the wrong node! No such channel for the passed counterparty_node_id {}", counterparty_node_id), msg.channel_id))
49484947
}
@@ -5057,11 +5056,13 @@ where
50575056
match peer_state.channel_by_id.entry(msg.channel_id) {
50585057
hash_map::Entry::Occupied(mut chan) => {
50595058
let funding_txo = chan.get().get_funding_txo();
5060-
let (htlcs_to_fail, monitor_update) = try_chan_entry!(self, chan.get_mut().revoke_and_ack(&msg, &self.logger), chan);
5061-
let update_res = self.chain_monitor.update_channel(funding_txo.unwrap(), monitor_update);
5062-
let update_id = monitor_update.update_id;
5063-
let res = handle_new_monitor_update!(self, update_res, update_id,
5064-
peer_state_lock, peer_state, per_peer_state, chan);
5059+
let (htlcs_to_fail, monitor_update_opt) = try_chan_entry!(self, chan.get_mut().revoke_and_ack(&msg, &self.logger), chan);
5060+
let res = if let Some(monitor_update) = monitor_update_opt {
5061+
let update_res = self.chain_monitor.update_channel(funding_txo.unwrap(), monitor_update);
5062+
let update_id = monitor_update.update_id;
5063+
handle_new_monitor_update!(self, update_res, update_id,
5064+
peer_state_lock, peer_state, per_peer_state, chan)
5065+
} else { Ok(()) };
50655066
(htlcs_to_fail, res)
50665067
},
50675068
hash_map::Entry::Vacant(_) => return Err(MsgHandleErrInternal::send_err_msg_no_close(format!("Got a message for a channel from the wrong node! No such channel for the passed counterparty_node_id {}", counterparty_node_id), msg.channel_id))

0 commit comments

Comments
 (0)