Skip to content

Commit

Permalink
daemon: rename CMD_SEND_HTLC_UPDATE to CMD_SEND_HTLC_ADD
Browse files Browse the repository at this point in the history
There are other updates than just adding an HTLC; make this explicit.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Mar 8, 2016
1 parent 4f67b59 commit 9830004
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 26 deletions.
10 changes: 5 additions & 5 deletions daemon/packets.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion daemon/peer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 6 additions & 7 deletions state.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -1035,8 +1034,8 @@ enum command_status state(const tal_t *ctx,

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) {
Expand Down
12 changes: 6 additions & 6 deletions state.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion state_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions test/test_state_coverage.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 9830004

Please sign in to comment.