Skip to content

Conversation

@joostjager
Copy link
Contributor

This commit changes ChainMonitor to queue monitor operations instead of applying them immediately. When watch_channel or update_channel is called, the operation is added to a pending queue and ChannelMonitorUpdateStatus::InProgress is returned. The actual monitor insertion/update and persistence happens when flush() is called.

This enables proper ordering of persistence: the ChannelManager can be persisted first, then flush() is called to persist the monitors. This ensures that on restart, the ChannelManager state is never ahead of the monitor state.

The background processor is updated to:

  1. Capture pending_monitor_operation_count() before persisting ChannelManager
  2. After ChannelManager persistence completes, call flush() with that count
  3. On shutdown, flush all remaining pending operations after final persistence

This commit changes `ChainMonitor` to queue monitor operations instead of
applying them immediately. When `watch_channel` or `update_channel` is
called, the operation is added to a pending queue and
`ChannelMonitorUpdateStatus::InProgress` is returned. The actual monitor
insertion/update and persistence happens when `flush()` is called.

This enables proper ordering of persistence: the `ChannelManager` can be
persisted first, then `flush()` is called to persist the monitors. This
ensures that on restart, the `ChannelManager` state is never ahead of the
monitor state.

The background processor is updated to:
1. Capture `pending_monitor_operation_count()` before persisting ChannelManager
2. After ChannelManager persistence completes, call `flush()` with that count
3. On shutdown, flush all remaining pending operations after final persistence

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@ldk-reviews-bot
Copy link

👋 Hi! I see this is a draft PR.
I'll wait to assign reviewers until you mark it as ready for review.
Just convert it out of draft status when you're ready for review!

@joostjager
Copy link
Contributor Author

Closing this PR as #4345 seems to be the easiest way to go

@joostjager joostjager closed this Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants