Browse Source

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>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
e7116284f0
  1. 19
      channeld/channel.c

19
channeld/channel.c

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

Loading…
Cancel
Save