Browse Source

daemon: rename num_htlcs to commit_tx_counter.

Much clearer name.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 9 years ago
parent
commit
1f9103c9d3
  1. 17
      daemon/packets.c
  2. 4
      daemon/peer.c
  3. 2
      daemon/peer.h

17
daemon/packets.c

@ -216,8 +216,8 @@ Pkt *pkt_update_signature(const tal_t *ctx, const struct peer *peer)
peer_sign_theircommit(peer, cur->their_commit, &sig); peer_sign_theircommit(peer, cur->their_commit, &sig);
u->sig = signature_to_proto(u, &sig); u->sig = signature_to_proto(u, &sig);
assert(peer->num_htlcs > 0); assert(peer->commit_tx_counter > 0);
peer_get_revocation_preimage(peer, peer->num_htlcs-1, &preimage); peer_get_revocation_preimage(peer, peer->commit_tx_counter-1, &preimage);
u->revocation_preimage = sha256_to_proto(u, &preimage); u->revocation_preimage = sha256_to_proto(u, &preimage);
return make_pkt(ctx, PKT__PKT_UPDATE_SIGNATURE, u); return make_pkt(ctx, PKT__PKT_UPDATE_SIGNATURE, u);
@ -230,7 +230,8 @@ Pkt *pkt_update_complete(const tal_t *ctx, const struct peer *peer)
update_complete__init(u); update_complete__init(u);
peer_get_revocation_preimage(peer, peer->num_htlcs-1, &preimage); assert(peer->commit_tx_counter > 0);
peer_get_revocation_preimage(peer, peer->commit_tx_counter-1, &preimage);
u->revocation_preimage = sha256_to_proto(u, &preimage); u->revocation_preimage = sha256_to_proto(u, &preimage);
return make_pkt(ctx, PKT__PKT_UPDATE_COMPLETE, u); return make_pkt(ctx, PKT__PKT_UPDATE_COMPLETE, u);
@ -473,7 +474,7 @@ Pkt *accept_pkt_htlc_add(const tal_t *ctx,
&cur->htlc->expiry, &cur->htlc->rhash); &cur->htlc->expiry, &cur->htlc->rhash);
peer_add_htlc_expiry(peer, &cur->htlc->expiry); peer_add_htlc_expiry(peer, &cur->htlc->expiry);
peer_get_revocation_hash(peer, peer->num_htlcs+1, peer_get_revocation_hash(peer, peer->commit_tx_counter+1,
&cur->our_revocation_hash); &cur->our_revocation_hash);
memcheck(&cur->their_revocation_hash, sizeof(cur->their_revocation_hash)); memcheck(&cur->their_revocation_hash, sizeof(cur->their_revocation_hash));
@ -532,7 +533,7 @@ Pkt *accept_pkt_htlc_fail(const tal_t *ctx, struct peer *peer, const Pkt *pkt)
funding_remove_htlc(&cur->cstate->a, i); funding_remove_htlc(&cur->cstate->a, i);
/* FIXME: Remove timer. */ /* FIXME: Remove timer. */
peer_get_revocation_hash(peer, peer->num_htlcs+1, peer_get_revocation_hash(peer, peer->commit_tx_counter+1,
&cur->our_revocation_hash); &cur->our_revocation_hash);
/* Now we create the commit tx pair. */ /* Now we create the commit tx pair. */
@ -588,7 +589,7 @@ Pkt *accept_pkt_htlc_timedout(const tal_t *ctx,
funding_remove_htlc(&cur->cstate->a, i); funding_remove_htlc(&cur->cstate->a, i);
/* FIXME: Remove timer. */ /* FIXME: Remove timer. */
peer_get_revocation_hash(peer, peer->num_htlcs+1, peer_get_revocation_hash(peer, peer->commit_tx_counter+1,
&cur->our_revocation_hash); &cur->our_revocation_hash);
/* Now we create the commit tx pair. */ /* Now we create the commit tx pair. */
@ -638,7 +639,7 @@ Pkt *accept_pkt_htlc_fulfill(const tal_t *ctx,
} }
funding_remove_htlc(&cur->cstate->a, i); funding_remove_htlc(&cur->cstate->a, i);
peer_get_revocation_hash(peer, peer->num_htlcs+1, peer_get_revocation_hash(peer, peer->commit_tx_counter+1,
&cur->our_revocation_hash); &cur->our_revocation_hash);
/* Now we create the commit tx pair. */ /* Now we create the commit tx pair. */
@ -694,7 +695,7 @@ static void update_to_new_htlcs(struct peer *peer)
peer->us.revocation_hash = cur->our_revocation_hash; peer->us.revocation_hash = cur->our_revocation_hash;
peer->them.revocation_hash = cur->their_revocation_hash; peer->them.revocation_hash = cur->their_revocation_hash;
peer->num_htlcs++; peer->commit_tx_counter++;
} }
Pkt *accept_pkt_update_accept(const tal_t *ctx, Pkt *accept_pkt_update_accept(const tal_t *ctx,

4
daemon/peer.c

@ -340,7 +340,7 @@ static struct peer *new_peer(struct lightningd_state *dstate,
peer->curr_cmd.cmd = INPUT_NONE; peer->curr_cmd.cmd = INPUT_NONE;
list_head_init(&peer->pending_cmd); list_head_init(&peer->pending_cmd);
peer->current_htlc = NULL; peer->current_htlc = NULL;
peer->num_htlcs = 0; peer->commit_tx_counter = 0;
peer->close_tx = NULL; peer->close_tx = NULL;
peer->cstate = NULL; peer->cstate = NULL;
peer->close_watch_timeout = NULL; peer->close_watch_timeout = NULL;
@ -1292,7 +1292,7 @@ static void set_htlc_command(struct peer *peer,
if (r_fulfill) if (r_fulfill)
peer->current_htlc->r = *r_fulfill; peer->current_htlc->r = *r_fulfill;
peer_get_revocation_hash(peer, peer->num_htlcs+1, peer_get_revocation_hash(peer, peer->commit_tx_counter+1,
&peer->current_htlc->our_revocation_hash); &peer->current_htlc->our_revocation_hash);
/* FIXME: Do we need current_htlc as idata arg? */ /* FIXME: Do we need current_htlc as idata arg? */

2
daemon/peer.h

@ -112,7 +112,7 @@ struct peer {
/* Current HTLC, if any. */ /* Current HTLC, if any. */
struct htlc_progress *current_htlc; struct htlc_progress *current_htlc;
/* Number of HTLC updates (== number of previous commit txs) */ /* Number of HTLC updates (== number of previous commit txs) */
u64 num_htlcs; u64 commit_tx_counter;
/* FIXME: Group closing fields together in anon struct. */ /* FIXME: Group closing fields together in anon struct. */
/* Closing tx and signature once we've generated it */ /* Closing tx and signature once we've generated it */

Loading…
Cancel
Save