daemon: batching of changes as per BOLT #2.

We now keep a list of commitment transaction states for "us" and
"them", as well as a "struct channel_state" for staged changes.

We manipulate these structures as we send out packets, receive
packets, or receive acknowledgement of packets.  In particular, we
update the other nodes' staging_cstate as we send out our requests,
and update our own staging_cstate are we receive acks.  When we
receive a request, we update both (as we immediately send out our
ack).

The RPC output is changed; rather than expose the complexity, we
expose our last committed state: what would happen if we have to drop
to the blockchain now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2016-03-31 17:13:20 +10:30
parent 017d199305
commit 5e7b3d02a1
12 changed files with 1318 additions and 1415 deletions

View File

@@ -61,6 +61,7 @@ extern const struct json_command getpeers_command;
extern const struct json_command newhtlc_command;
extern const struct json_command fulfillhtlc_command;
extern const struct json_command failhtlc_command;
extern const struct json_command commit_command;
extern const struct json_command mocktime_command;
extern const struct json_command close_command;
#endif /* LIGHTNING_DAEMON_JSONRPC_H */