Commit 491f582
committed
Ack monitor events immediately
Currently, the resolution of HTLCs (and decisions on when HTLCs can be
forwarded) is the responsibility of Channel objects (a part of ChannelManager)
until the channel is closed, and then the ChannelMonitor thereafter. This leads
to some complexity around race conditions for HTLCs right around channel
closure. Additionally, there is lots of complexity reconstructing the state of
all HTLCs in the ChannelManager deserialization/loading logic.
Instead, we want to do all resolution in ChannelMonitors (in response to
ChannelMonitorUpdates) and pass them back to ChannelManager in the form of
MonitorEvents (similar to how HTLCs are resolved after channels are closed). In
order to have reliable resolution, we'll need to keep MonitorEvents around in
the ChannelMonitor until the ChannelManager has finished processing them. This
will simplify things - on restart instead of examining the set of HTLCs in
monitors we can simply replay all the pending MonitorEvents.
Here for the purposes of merging initial support for persistent monitor events,
we ack each immediately after it is received/handled by the ChannelManager,
which is equivalent to the behavior we had prior to monitor events becoming
persistent.
In upcoming work, we'll want to have much more special handling for HTLCUpdate
monitor events in particular -- e.g. for outbound payment claim events, we
should only ACK the monitor event when the PaymentSent event is processed,
until that point we want it to keep being provided back to us on startup.
All the other monitor events are trivial to ACK, since they don't need to be
re-processed on startup.1 parent cb4a804 commit 491f582
1 file changed
+11
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
13522 | 13523 | | |
13523 | 13524 | | |
13524 | 13525 | | |
13525 | | - | |
| 13526 | + | |
| 13527 | + | |
13526 | 13528 | | |
13527 | 13529 | | |
13528 | 13530 | | |
| |||
13572 | 13574 | | |
13573 | 13575 | | |
13574 | 13576 | | |
| 13577 | + | |
13575 | 13578 | | |
13576 | 13579 | | |
13577 | 13580 | | |
| |||
13605 | 13608 | | |
13606 | 13609 | | |
13607 | 13610 | | |
| 13611 | + | |
| 13612 | + | |
| 13613 | + | |
13608 | 13614 | | |
13609 | 13615 | | |
13610 | 13616 | | |
| |||
13626 | 13632 | | |
13627 | 13633 | | |
13628 | 13634 | | |
| 13635 | + | |
| 13636 | + | |
| 13637 | + | |
13629 | 13638 | | |
13630 | 13639 | | |
13631 | 13640 | | |
13632 | 13641 | | |
13633 | 13642 | | |
13634 | 13643 | | |
13635 | 13644 | | |
| 13645 | + | |
13636 | 13646 | | |
13637 | 13647 | | |
13638 | 13648 | | |
| |||
0 commit comments