Skip to content

Commit 2da1553

Browse files
nicolftphlip9
authored andcommitted
Bypass channel monitor sync requests when no partition key given
NOTE(phlip9): * Significantly reduces # of channel monitor persists during _transacion-only sync_. * Backported from LDK master. See PR lightningdevkit#4544 for details.
1 parent e30bc76 commit 2da1553

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

lightning/src/chain/chainmonitor.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ where
570570
channel_id_bytes[2],
571571
channel_id_bytes[3],
572572
]);
573-
channel_id_u32.wrapping_add(best_height.unwrap_or_default())
573+
best_height.map(|height| channel_id_u32.wrapping_add(height))
574574
};
575575

576576
let partition_factor = if channel_count < 15 {
@@ -580,12 +580,8 @@ where
580580
};
581581

582582
let has_pending_claims = monitor_state.monitor.has_pending_claims();
583-
if has_pending_claims || get_partition_key(channel_id) % partition_factor == 0 {
584-
log_trace!(
585-
logger,
586-
"Syncing Channel Monitor for channel {}",
587-
log_funding_info!(monitor)
588-
);
583+
if has_pending_claims || get_partition_key(channel_id).is_some_and(|key| key % partition_factor == 0) {
584+
log_trace!(logger, "Syncing Channel Monitor");
589585
// Even though we don't track monitor updates from chain-sync as pending, we still want
590586
// updates per-channel to be well-ordered so that users don't see a
591587
// `ChannelMonitorUpdate` after a channel persist for a channel with the same

0 commit comments

Comments
 (0)