daemon: rename CMD_SEND_HTLC_UPDATE to CMD_SEND_HTLC_ADD

There are other updates than just adding an HTLC; make this explicit.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2016-03-08 10:42:15 +10:30
parent 4f67b59c26
commit 983000428f
6 changed files with 25 additions and 26 deletions

View File

@ -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);

View File

@ -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,

13
state.c
View File

@ -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) {

12
state.h
View File

@ -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);

View File

@ -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,

View File

@ -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;