mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-21 16:14:23 +01:00
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:
@@ -30,25 +30,11 @@ enum state {
|
||||
STATE_OPEN_WAIT_FOR_COMPLETE_THEIRANCHOR,
|
||||
|
||||
/*
|
||||
* Normal update loop.
|
||||
*
|
||||
* NOTE: High and low prios must alternate!
|
||||
* Normal state.
|
||||
*/
|
||||
STATE_NORMAL_LOWPRIO,
|
||||
STATE_NORMAL_HIGHPRIO,
|
||||
|
||||
STATE_WAIT_FOR_HTLC_ACCEPT_LOWPRIO,
|
||||
STATE_WAIT_FOR_HTLC_ACCEPT_HIGHPRIO,
|
||||
|
||||
STATE_WAIT_FOR_UPDATE_ACCEPT_LOWPRIO,
|
||||
STATE_WAIT_FOR_UPDATE_ACCEPT_HIGHPRIO,
|
||||
STATE_NORMAL,
|
||||
STATE_NORMAL_COMMITTING,
|
||||
|
||||
STATE_WAIT_FOR_UPDATE_COMPLETE_LOWPRIO,
|
||||
STATE_WAIT_FOR_UPDATE_COMPLETE_HIGHPRIO,
|
||||
|
||||
STATE_WAIT_FOR_UPDATE_SIG_LOWPRIO,
|
||||
STATE_WAIT_FOR_UPDATE_SIG_HIGHPRIO,
|
||||
|
||||
/*
|
||||
* Closing.
|
||||
*/
|
||||
@@ -195,15 +181,9 @@ enum state_input {
|
||||
/* Updating the commit transaction: your HTLC failed upstream */
|
||||
PKT_UPDATE_FAIL_HTLC = PKT__PKT_UPDATE_FAIL_HTLC,
|
||||
|
||||
/* Update replies: */
|
||||
PKT_UPDATE_ACCEPT = PKT__PKT_UPDATE_ACCEPT,
|
||||
/* Only for PKT_UPDATE_ADD_HTLC. */
|
||||
PKT_UPDATE_DECLINE_HTLC = PKT__PKT_UPDATE_DECLINE_HTLC,
|
||||
|
||||
/* Reply to PKT_UPDATE_ACCEPT */
|
||||
PKT_UPDATE_SIGNATURE = PKT__PKT_UPDATE_SIGNATURE,
|
||||
/* Reply to PKT_UPDATE_SIGNATURE */
|
||||
PKT_UPDATE_COMPLETE = PKT__PKT_UPDATE_COMPLETE,
|
||||
/* Committing updates */
|
||||
PKT_UPDATE_COMMIT = PKT__PKT_UPDATE_COMMIT,
|
||||
PKT_UPDATE_REVOCATION = PKT__PKT_UPDATE_REVOCATION,
|
||||
|
||||
/* Mutual close sequence. */
|
||||
PKT_CLOSE_CLEARING = PKT__PKT_CLOSE_CLEARING,
|
||||
@@ -279,6 +259,7 @@ enum state_input {
|
||||
CMD_SEND_HTLC_ADD,
|
||||
CMD_SEND_HTLC_FULFILL,
|
||||
CMD_SEND_HTLC_FAIL,
|
||||
CMD_SEND_COMMIT,
|
||||
CMD_CLOSE,
|
||||
|
||||
/* Connection lost/timedout with other node. */
|
||||
|
||||
Reference in New Issue
Block a user