daemon: save acked changes, so we can process them when confirmed on both sides.

We need to know when changes are fully committed by both sides:
1) For their HTLC_ADDs, this is when we can fulfill/fail/route.
2) For their HTLC_FAILs, this is when we can fail incoming.

For HTLC_FULFULL we don't need to wait: as soon as we know the preimage
we can propogate it.

For the moment, we simply log and assert; acting on it comes later.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2016-06-29 06:49:20 +09:30
parent eeb9b9de84
commit f1af56fcee
4 changed files with 125 additions and 0 deletions

View File

@@ -73,6 +73,8 @@ struct commit_info {
struct sha256 *revocation_preimage;
/* unacked changes (already applied to staging_cstate) */
union htlc_staging *unacked_changes;
/* acked changes (already applied to staging_cstate) */
union htlc_staging *acked_changes;
};
struct peer_visible_state {
@@ -228,6 +230,14 @@ void remote_changes_pending(struct peer *peer);
void add_unacked(struct peer_visible_state *which,
const union htlc_staging *stage);
/* These unacked changes are now acked; add them to acked set. */
void add_acked_changes(union htlc_staging **acked,
const union htlc_staging *changes);
/* Both sides are committed to these changes they proposed. */
void peer_both_committed_to(struct peer *peer,
const union htlc_staging *changes, enum channel_side side);
/* Peer has recieved revocation. */
void peer_update_complete(struct peer *peer);