diff --git a/daemon/packets.c b/daemon/packets.c index 12c4d9e58..3b233783d 100644 --- a/daemon/packets.c +++ b/daemon/packets.c @@ -134,8 +134,8 @@ Pkt *pkt_open_complete(const tal_t *ctx, const struct peer *peer) return make_pkt(ctx, PKT__PKT_OPEN_COMPLETE, o); } -Pkt *pkt_htlc_update(const tal_t *ctx, const struct peer *peer, - const struct htlc_progress *htlc_prog) +Pkt *pkt_htlc_add(const tal_t *ctx, const struct peer *peer, + const struct htlc_progress *htlc_prog) { UpdateAddHtlc *u = tal(ctx, UpdateAddHtlc); @@ -423,9 +423,9 @@ static Pkt *decline_htlc(const tal_t *ctx, const char *why) return make_pkt(ctx, PKT__PKT_UPDATE_DECLINE_HTLC, d); } -Pkt *accept_pkt_htlc_update(const tal_t *ctx, - struct peer *peer, const Pkt *pkt, - Pkt **decline) +Pkt *accept_pkt_htlc_add(const tal_t *ctx, + struct peer *peer, const Pkt *pkt, + Pkt **decline) { const UpdateAddHtlc *u = pkt->update_add_htlc; struct htlc_progress *cur = tal(peer, struct htlc_progress); diff --git a/daemon/peer.c b/daemon/peer.c index 781947fba..a7e59be63 100644 --- a/daemon/peer.c +++ b/daemon/peer.c @@ -1388,7 +1388,7 @@ static void do_newhtlc(struct peer *peer, struct newhtlc *newhtlc) set_htlc_command(peer, cstate, newhtlc->jsoncmd, &cstate->a.htlcs[tal_count(cstate->a.htlcs)-1], - CMD_SEND_HTLC_UPDATE, NULL); + CMD_SEND_HTLC_ADD, NULL); } static void json_newhtlc(struct command *cmd, diff --git a/state.c b/state.c index 97b3d6e17..da6ba8a8a 100644 --- a/state.c +++ b/state.c @@ -403,11 +403,10 @@ enum command_status state(const tal_t *ctx, case STATE_NORMAL_LOWPRIO: case STATE_NORMAL_HIGHPRIO: assert(peer->cond == PEER_CMD_OK); - if (input_is(input, CMD_SEND_HTLC_UPDATE)) { + if (input_is(input, CMD_SEND_HTLC_ADD)) { /* We are to send an HTLC update. */ queue_pkt(out, - pkt_htlc_update(ctx, peer, - idata->htlc_prog)); + pkt_htlc_add(ctx, peer, idata->htlc_prog)); change_peer_cond(peer, PEER_CMD_OK, PEER_BUSY); return next_state(peer, cstatus, prio(peer->state, STATE_WAIT_FOR_HTLC_ACCEPT)); @@ -439,7 +438,7 @@ enum command_status state(const tal_t *ctx, goto start_closing; } else if (input_is(input, PKT_UPDATE_ADD_HTLC)) { change_peer_cond(peer, PEER_CMD_OK, PEER_BUSY); - goto accept_htlc_update; + goto accept_htlc_add; } else if (input_is(input, PKT_UPDATE_FULFILL_HTLC)) { change_peer_cond(peer, PEER_CMD_OK, PEER_BUSY); goto accept_htlc_fulfill; @@ -484,7 +483,7 @@ enum command_status state(const tal_t *ctx, complete_cmd(peer, &cstatus, CMD_REQUEUE); /* Stay busy, since we're processing theirs. */ change_peer_cond(peer, PEER_CMD_OK, PEER_BUSY); - goto accept_htlc_update; + goto accept_htlc_add; } else if (input_is(input, PKT_UPDATE_FULFILL_HTLC)) { /* If we're high priority, ignore their packet */ if (high_priority(peer->state)) @@ -1035,8 +1034,8 @@ them_unilateral: return next_state(peer, cstatus, STATE_CLOSE_WAIT_SPENDTHEM); -accept_htlc_update: - err = accept_pkt_htlc_update(ctx, peer, idata->pkt, &decline); +accept_htlc_add: + err = accept_pkt_htlc_add(ctx, peer, idata->pkt, &decline); if (err) goto err_start_unilateral_close; if (decline) { diff --git a/state.h b/state.h index 563d0ee31..b206415da 100644 --- a/state.h +++ b/state.h @@ -50,7 +50,7 @@ static inline bool input_is(enum state_input a, enum state_input b) { if (b == CMD_SEND_UPDATE_ANY) { /* Single | here, we want to record all. */ - return input_is(a, CMD_SEND_HTLC_UPDATE) + return input_is(a, CMD_SEND_HTLC_ADD) | input_is(a, CMD_SEND_HTLC_FULFILL) | input_is(a, CMD_SEND_HTLC_TIMEDOUT) | input_is(a, CMD_SEND_HTLC_FAIL); @@ -103,8 +103,8 @@ Pkt *pkt_open(const tal_t *ctx, const struct peer *peer, Pkt *pkt_anchor(const tal_t *ctx, const struct peer *peer); Pkt *pkt_open_commit_sig(const tal_t *ctx, const struct peer *peer); Pkt *pkt_open_complete(const tal_t *ctx, const struct peer *peer); -Pkt *pkt_htlc_update(const tal_t *ctx, const struct peer *peer, - const struct htlc_progress *htlc_prog); +Pkt *pkt_htlc_add(const tal_t *ctx, const struct peer *peer, + const struct htlc_progress *htlc_prog); Pkt *pkt_htlc_fulfill(const tal_t *ctx, const struct peer *peer, const struct htlc_progress *htlc_prog); Pkt *pkt_htlc_timedout(const tal_t *ctx, const struct peer *peer, @@ -135,9 +135,9 @@ Pkt *accept_pkt_open_commit_sig(const tal_t *ctx, Pkt *accept_pkt_open_complete(const tal_t *ctx, struct peer *peer, const Pkt *pkt); -Pkt *accept_pkt_htlc_update(const tal_t *ctx, - struct peer *peer, const Pkt *pkt, - Pkt **decline); +Pkt *accept_pkt_htlc_add(const tal_t *ctx, + struct peer *peer, const Pkt *pkt, + Pkt **decline); Pkt *accept_pkt_htlc_fail(const tal_t *ctx, struct peer *peer, const Pkt *pkt); diff --git a/state_types.h b/state_types.h index d9861397c..c4a1db4c7 100644 --- a/state_types.h +++ b/state_types.h @@ -274,7 +274,7 @@ enum state_input { /* Commands */ CMD_OPEN_WITH_ANCHOR, CMD_OPEN_WITHOUT_ANCHOR, - CMD_SEND_HTLC_UPDATE, + CMD_SEND_HTLC_ADD, CMD_SEND_HTLC_FULFILL, CMD_SEND_HTLC_TIMEDOUT, CMD_SEND_HTLC_FAIL, diff --git a/test/test_state_coverage.c b/test/test_state_coverage.c index 5b98fd860..66e96d036 100644 --- a/test/test_state_coverage.c +++ b/test/test_state_coverage.c @@ -36,7 +36,7 @@ enum failure { FAIL_ACCEPT_ANCHOR, FAIL_ACCEPT_OPEN_COMMIT_SIG, FAIL_ACCEPT_OPEN_COMPLETE, - FAIL_ACCEPT_HTLC_UPDATE, + FAIL_ACCEPT_HTLC_ADD, FAIL_ACCEPT_HTLC_FAIL, FAIL_ACCEPT_HTLC_TIMEDOUT, FAIL_ACCEPT_HTLC_FULFILL, @@ -416,7 +416,7 @@ static const union input dup_idata(const tal_t *ctx, if (input_is_pkt(input)) i.pkt = (Pkt *)tal_strdup(ctx, (const char *)idata->pkt); - else if (input == CMD_SEND_HTLC_UPDATE + else if (input == CMD_SEND_HTLC_ADD || input == CMD_SEND_HTLC_FULFILL || input == CMD_SEND_HTLC_FAIL || input == CMD_SEND_HTLC_TIMEDOUT) { @@ -618,7 +618,7 @@ Pkt *pkt_open_complete(const tal_t *ctx, const struct peer *peer) return new_pkt(ctx, PKT_OPEN_COMPLETE); } -Pkt *pkt_htlc_update(const tal_t *ctx, const struct peer *peer, +Pkt *pkt_htlc_add(const tal_t *ctx, const struct peer *peer, const struct htlc_progress *htlc_prog) { return htlc_pkt(ctx, "PKT_UPDATE_ADD_HTLC", htlc_prog->htlc.id); @@ -726,11 +726,11 @@ Pkt *accept_pkt_open_complete(const tal_t *ctx, return NULL; } -Pkt *accept_pkt_htlc_update(const tal_t *ctx, +Pkt *accept_pkt_htlc_add(const tal_t *ctx, struct peer *peer, const Pkt *pkt, Pkt **decline) { - if (fail(peer, FAIL_ACCEPT_HTLC_UPDATE)) + if (fail(peer, FAIL_ACCEPT_HTLC_ADD)) return pkt_err(ctx, "Error inject"); /* This is the current htlc: If they propose it, it's to us. */ @@ -2110,7 +2110,7 @@ static void run_peer(const struct peer *peer, /* Add a new HTLC if not at max. */ if (copy.num_htlcs_to_them < MAX_HTLCS) { - copy.core.current_command = CMD_SEND_HTLC_UPDATE; + copy.core.current_command = CMD_SEND_HTLC_ADD; idata->htlc_prog = tal(idata, struct htlc_progress); idata->htlc_prog->adding = true; idata->htlc_prog->htlc.to_them = true;