channeld: move reestablish retransmission below checks.

This makes it a bit clearer, but also means we do all checks before
sending any packets.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2018-08-17 14:36:36 +09:30 committed by Christian Decker
parent 43156643b4
commit e7116284f0

View File

@ -1836,7 +1836,7 @@ static void peer_reconnect(struct peer *peer,
struct channel_id channel_id;
/* Note: BOLT #2 uses these names, which are sender-relative! */
u64 next_local_commitment_number, next_remote_revocation_number;
bool retransmit_revoke_and_ack;
bool retransmit_revoke_and_ack, retransmit_commitment_signed;
struct htlc_map_iter it;
const struct htlc *htlc;
u8 *msg;
@ -1960,11 +1960,6 @@ static void peer_reconnect(struct peer *peer,
} else
retransmit_revoke_and_ack = false;
/* We have to re-send in the same order we sent originally:
* revoke_and_ack (usually) alters our next commitment. */
if (retransmit_revoke_and_ack && !peer->last_was_revoke)
resend_revoke(peer);
/* BOLT #2:
*
* - if `next_local_commitment_number` is equal to the commitment
@ -1982,7 +1977,7 @@ static void peer_reconnect(struct peer *peer,
PRIu64,
next_local_commitment_number);
resend_commitment(peer, peer->last_sent_commit);
retransmit_commitment_signed = true;
/* BOLT #2:
*
@ -1999,6 +1994,16 @@ static void peer_reconnect(struct peer *peer,
" vs %"PRIu64,
next_local_commitment_number,
peer->next_index[REMOTE]);
else
retransmit_commitment_signed = false;
/* We have to re-send in the same order we sent originally:
* revoke_and_ack (usually) alters our next commitment. */
if (retransmit_revoke_and_ack && !peer->last_was_revoke)
resend_revoke(peer);
if (retransmit_commitment_signed)
resend_commitment(peer, peer->last_sent_commit);
/* This covers the case where we sent revoke after commit. */
if (retransmit_revoke_and_ack && peer->last_was_revoke)