Skip to content

Commit 0a3c718

Browse files
committed
f: respond to comments
1 parent 996f65b commit 0a3c718

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

lightning/src/chain/chainmonitor.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -639,19 +639,22 @@ where C::Target: chain::Filter,
639639
/// Depending on the implementation of [`Persist::archive_persisted_channel`] the monitor
640640
/// data could be moved to an archive location or removed entirely.
641641
pub fn archive_fully_resolved_channel_monitors(&self) {
642-
let mut have_monitors_to_persist_or_prune = false;
643-
for (_, monitor_holder) in self.monitors.read().unwrap().iter() {
642+
let mut have_monitors_to_prune = false;
643+
for (funding_txo, monitor_holder) in self.monitors.read().unwrap().iter() {
644644
let logger = WithChannelMonitor::from(&self.logger, &monitor_holder.monitor, None);
645-
let (is_fully_resolved, needs_persistence) = monitor_holder.monitor.process_claim_resolution_status(&logger);
646-
if is_fully_resolved || needs_persistence {
647-
have_monitors_to_persist_or_prune = true;
645+
let (is_fully_resolved, needs_persistence) = monitor_holder.monitor.check_and_update_full_resolution_status(&logger);
646+
if is_fully_resolved {
647+
have_monitors_to_prune = true;
648+
}
649+
if needs_persistence {
650+
self.persister.update_persisted_channel(*funding_txo, None, &monitor_holder.monitor);
648651
}
649652
}
650-
if have_monitors_to_persist_or_prune {
653+
if have_monitors_to_prune {
651654
let mut monitors = self.monitors.write().unwrap();
652655
monitors.retain(|funding_txo, monitor_holder| {
653656
let logger = WithChannelMonitor::from(&self.logger, &monitor_holder.monitor, None);
654-
let (is_fully_resolved, needs_persistence) = monitor_holder.monitor.process_claim_resolution_status(&logger);
657+
let (is_fully_resolved, _) = monitor_holder.monitor.check_and_update_full_resolution_status(&logger);
655658
if is_fully_resolved {
656659
log_info!(logger,
657660
"Archiving fully resolved ChannelMonitor for funding txo {}",
@@ -660,9 +663,6 @@ where C::Target: chain::Filter,
660663
self.persister.archive_persisted_channel(*funding_txo);
661664
false
662665
} else {
663-
if needs_persistence {
664-
self.persister.update_persisted_channel(*funding_txo, None, &monitor_holder.monitor);
665-
}
666666
true
667667
}
668668
});

lightning/src/chain/channelmonitor.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1997,11 +1997,11 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
19971997
/// Additionally updates the empty balances height if necessary.
19981998
///
19991999
/// This function returns a tuple of two booleans, the first indicating whether the monitor is
2000-
/// fully resolved, and the second whether the monitor needs persistence as a consequence of
2001-
/// checking its claim resolution status.
2000+
/// fully resolved, and the second whether the monitor needs persistence to ensure it is
2001+
/// reliably marked as resolved within 4032 blocks.
20022002
/// The first boolean is true only if [`Self::get_claimable_balances`] has been empty for at least
20032003
/// 4032 blocks as an additional protection against any bugs resulting in spuriously empty balance sets.
2004-
pub fn process_claim_resolution_status<L: Logger>(&self, logger: &L) -> (bool, bool) {
2004+
pub fn check_and_update_full_resolution_status<L: Logger>(&self, logger: &L) -> (bool, bool) {
20052005
let mut is_all_funds_claimed = self.get_claimable_balances().is_empty();
20062006
let current_height = self.current_best_block().height;
20072007
let mut inner = self.inner.lock().unwrap();

0 commit comments

Comments
 (0)