mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-17 19:03:42 +01:00
gossipd / plugin: clean up names in struct route_hop.
We're going to unify them, but the names are not the normal ones. Fix that first. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
9dadcc858b
commit
e531a38963
@ -2738,8 +2738,8 @@ struct route_hop **get_route(const tal_t *ctx, struct routing_state *rstate,
|
||||
int idx = half_chan_to(n, route[i]);
|
||||
c = &route[i]->half[idx];
|
||||
hops[i] = tal(hops, struct route_hop);
|
||||
hops[i]->channel_id = route[i]->scid;
|
||||
hops[i]->nodeid = n->id;
|
||||
hops[i]->scid = route[i]->scid;
|
||||
hops[i]->node_id = n->id;
|
||||
hops[i]->amount = total_amount;
|
||||
hops[i]->delay = total_delay;
|
||||
hops[i]->direction = idx;
|
||||
|
@ -324,9 +324,9 @@ get_channel(const struct routing_state *rstate,
|
||||
}
|
||||
|
||||
struct route_hop {
|
||||
struct short_channel_id channel_id;
|
||||
struct short_channel_id scid;
|
||||
int direction;
|
||||
struct node_id nodeid;
|
||||
struct node_id node_id;
|
||||
struct amount_msat amount;
|
||||
u32 delay;
|
||||
struct pubkey *blinding;
|
||||
|
@ -329,9 +329,8 @@ static void json_add_route_hop(struct json_stream *r, char const *n,
|
||||
{
|
||||
/* Imitate what getroute/sendpay use */
|
||||
json_object_start(r, n);
|
||||
json_add_node_id(r, "id", &h->nodeid);
|
||||
json_add_short_channel_id(r, "channel",
|
||||
&h->channel_id);
|
||||
json_add_node_id(r, "id", &h->node_id);
|
||||
json_add_short_channel_id(r, "channel", &h->scid);
|
||||
json_add_num(r, "direction", h->direction);
|
||||
json_add_amount_msat_compat(r, h->amount, "msatoshi", "amount_msat");
|
||||
json_add_num(r, "delay", h->delay);
|
||||
|
@ -62,8 +62,8 @@ struct route_hop *fromwire_route_hop(const tal_t *ctx,
|
||||
struct route_hop *entry = tal(ctx, struct route_hop);
|
||||
size_t enclen;
|
||||
|
||||
fromwire_node_id(pptr, max, &entry->nodeid);
|
||||
fromwire_short_channel_id(pptr, max, &entry->channel_id);
|
||||
fromwire_node_id(pptr, max, &entry->node_id);
|
||||
fromwire_short_channel_id(pptr, max, &entry->scid);
|
||||
entry->direction = fromwire_u8(pptr, max);
|
||||
entry->amount = fromwire_amount_msat(pptr, max);
|
||||
entry->delay = fromwire_u32(pptr, max);
|
||||
@ -82,8 +82,8 @@ struct route_hop *fromwire_route_hop(const tal_t *ctx,
|
||||
|
||||
void towire_route_hop(u8 **pptr, const struct route_hop *entry)
|
||||
{
|
||||
towire_node_id(pptr, &entry->nodeid);
|
||||
towire_short_channel_id(pptr, &entry->channel_id);
|
||||
towire_node_id(pptr, &entry->node_id);
|
||||
towire_short_channel_id(pptr, &entry->scid);
|
||||
towire_u8(pptr, entry->direction);
|
||||
towire_amount_msat(pptr, entry->amount);
|
||||
towire_u32(pptr, entry->delay);
|
||||
|
@ -999,7 +999,7 @@ send_payment_core(struct lightningd *ld,
|
||||
if (offer_err)
|
||||
return offer_err;
|
||||
|
||||
channel = active_channel_by_id(ld, &first_hop->nodeid, NULL);
|
||||
channel = active_channel_by_id(ld, &first_hop->node_id, NULL);
|
||||
if (!channel) {
|
||||
struct json_stream *data
|
||||
= json_stream_fail(cmd, PAY_TRY_OTHER_ROUTE,
|
||||
@ -1007,8 +1007,9 @@ send_payment_core(struct lightningd *ld,
|
||||
"peer found");
|
||||
|
||||
json_add_routefail_info(data, 0, WIRE_UNKNOWN_NEXT_PEER,
|
||||
&ld->id, &first_hop->channel_id,
|
||||
node_id_idx(&ld->id, &first_hop->nodeid),
|
||||
&ld->id, &first_hop->scid,
|
||||
node_id_idx(&ld->id,
|
||||
&first_hop->node_id),
|
||||
NULL);
|
||||
json_object_end(data);
|
||||
return command_failed(cmd, data);
|
||||
@ -1020,7 +1021,7 @@ send_payment_core(struct lightningd *ld,
|
||||
if (failmsg) {
|
||||
fail = immediate_routing_failure(cmd, ld,
|
||||
fromwire_peektype(failmsg),
|
||||
&first_hop->channel_id,
|
||||
&first_hop->scid,
|
||||
&channel->peer->id);
|
||||
|
||||
return sendpay_fail(
|
||||
@ -1115,7 +1116,7 @@ send_payment(struct lightningd *ld,
|
||||
path = sphinx_path_new(tmpctx, rhash->u.u8);
|
||||
/* Extract IDs for each hop: create_onionpacket wants array. */
|
||||
for (i = 0; i < n_hops; i++)
|
||||
ids[i] = route[i].nodeid;
|
||||
ids[i] = route[i].node_id;
|
||||
|
||||
/* Create sphinx path */
|
||||
for (i = 0; i < n_hops - 1; i++) {
|
||||
@ -1125,7 +1126,7 @@ send_payment(struct lightningd *ld,
|
||||
sphinx_add_hop(path, &pubkey,
|
||||
take(onion_nonfinal_hop(NULL,
|
||||
should_use_tlv(route[i].style),
|
||||
&route[i + 1].channel_id,
|
||||
&route[i + 1].scid,
|
||||
route[i + 1].amount,
|
||||
base_expiry + route[i + 1].delay,
|
||||
route[i].blinding,
|
||||
@ -1170,7 +1171,7 @@ send_payment(struct lightningd *ld,
|
||||
/* Copy channels used along the route. */
|
||||
channels = tal_arr(tmpctx, struct short_channel_id, n_hops);
|
||||
for (i = 0; i < n_hops; ++i)
|
||||
channels[i] = route[i].channel_id;
|
||||
channels[i] = route[i].scid;
|
||||
|
||||
log_info(ld->log, "Sending %s over %zu hops to deliver %s",
|
||||
type_to_string(tmpctx, struct amount_msat, &route[0].amount),
|
||||
@ -1218,15 +1219,15 @@ param_route_hop(struct command *cmd, const char *name, const char *buffer,
|
||||
/* Parsing of actual values including sanity check for all parsed
|
||||
* values. */
|
||||
if (!idtok) {
|
||||
memset(&res->nodeid, 0, sizeof(struct node_id));
|
||||
} else if (!json_to_node_id(buffer, idtok, &res->nodeid)) {
|
||||
memset(&res->node_id, 0, sizeof(struct node_id));
|
||||
} else if (!json_to_node_id(buffer, idtok, &res->node_id)) {
|
||||
return command_fail_badparam(cmd, name, buffer, idtok,
|
||||
"should be a node_id");
|
||||
}
|
||||
|
||||
if (!channeltok) {
|
||||
memset(&res->channel_id, 0, sizeof(struct short_channel_id));
|
||||
} else if (!json_to_short_channel_id(buffer, channeltok, &res->channel_id)) {
|
||||
memset(&res->scid, 0, sizeof(struct short_channel_id));
|
||||
} else if (!json_to_short_channel_id(buffer, channeltok, &res->scid)) {
|
||||
return command_fail_badparam(cmd, name, buffer, channeltok,
|
||||
"should be a short_channel_id");
|
||||
}
|
||||
@ -1394,9 +1395,9 @@ static struct command_result *param_route_hops(struct command *cmd,
|
||||
default_style = ROUTE_HOP_LEGACY;
|
||||
|
||||
(*hops)[i].amount = *msat;
|
||||
(*hops)[i].nodeid = *id;
|
||||
(*hops)[i].node_id = *id;
|
||||
(*hops)[i].delay = *delay;
|
||||
(*hops)[i].channel_id = *channel;
|
||||
(*hops)[i].scid = *channel;
|
||||
(*hops)[i].blinding = blinding;
|
||||
(*hops)[i].enctlv = enctlv;
|
||||
(*hops)[i].style = style ? *style : default_style;
|
||||
|
@ -395,7 +395,7 @@ static void payment_exclude_most_expensive(struct payment *p)
|
||||
worst = fee;
|
||||
}
|
||||
}
|
||||
channel_hints_update(p, e->channel_id, e->direction, false, false,
|
||||
channel_hints_update(p, e->scid, e->direction, false, false,
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
@ -411,7 +411,7 @@ static void payment_exclude_longest_delay(struct payment *p)
|
||||
worst = delay;
|
||||
}
|
||||
}
|
||||
channel_hints_update(p, e->channel_id, e->direction, false, false,
|
||||
channel_hints_update(p, e->scid, e->direction, false, false,
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
@ -457,7 +457,7 @@ static struct channel_hint *payment_chanhints_get(struct payment *p,
|
||||
struct channel_hint *curhint;
|
||||
for (size_t j = 0; j < tal_count(root->channel_hints); j++) {
|
||||
curhint = &root->channel_hints[j];
|
||||
if (short_channel_id_eq(&curhint->scid.scid, &h->channel_id) &&
|
||||
if (short_channel_id_eq(&curhint->scid.scid, &h->scid) &&
|
||||
curhint->scid.dir == h->direction) {
|
||||
return curhint;
|
||||
}
|
||||
@ -700,13 +700,13 @@ static struct route_hop *route_hops_from_route(const tal_t *ctx,
|
||||
for (size_t i = 0; i < tal_count(hops); i++) {
|
||||
const struct gossmap_node *dst;
|
||||
|
||||
hops[i].channel_id = gossmap_chan_scid(gossmap, r[i]->c);
|
||||
hops[i].scid = gossmap_chan_scid(gossmap, r[i]->c);
|
||||
hops[i].direction = r[i]->dir;
|
||||
hops[i].blinding = NULL;
|
||||
|
||||
/* nodeid is nodeid of *dst* */
|
||||
dst = gossmap_nth_node(gossmap, r[i]->c, !r[i]->dir);
|
||||
gossmap_node_get_id(gossmap, dst, &hops[i].nodeid);
|
||||
gossmap_node_get_id(gossmap, dst, &hops[i].node_id);
|
||||
if (gossmap_node_get_feature(gossmap, dst, OPT_VAR_ONION) != -1)
|
||||
hops[i].style = ROUTE_HOP_TLV;
|
||||
else
|
||||
@ -1038,7 +1038,7 @@ static void payment_result_infer(struct route_hop *route,
|
||||
assert(i <= len);
|
||||
|
||||
if (r->erring_node == NULL)
|
||||
r->erring_node = &route[i-1].nodeid;
|
||||
r->erring_node = &route[i-1].node_id;
|
||||
|
||||
/* The above assert was enough for the erring_node, but might be off
|
||||
* by one on channel and direction, in case the destination failed on
|
||||
@ -1047,7 +1047,7 @@ static void payment_result_infer(struct route_hop *route,
|
||||
return;
|
||||
|
||||
if (r->erring_channel == NULL)
|
||||
r->erring_channel = &route[i].channel_id;
|
||||
r->erring_channel = &route[i].scid;
|
||||
|
||||
if (r->erring_direction == NULL)
|
||||
r->erring_direction = &route[i].direction;
|
||||
@ -1059,7 +1059,7 @@ static void report_tampering(struct payment *p,
|
||||
size_t report_pos,
|
||||
const char *style)
|
||||
{
|
||||
const struct node_id *id = &p->route[report_pos].nodeid;
|
||||
const struct node_id *id = &p->route[report_pos].node_id;
|
||||
|
||||
if (report_pos == 0) {
|
||||
paymod_log(p, LOG_UNUSUAL,
|
||||
@ -1074,7 +1074,7 @@ static void report_tampering(struct payment *p,
|
||||
type_to_string(tmpctx, struct node_id, id),
|
||||
report_pos,
|
||||
type_to_string(tmpctx, struct node_id,
|
||||
&p->route[report_pos-1].nodeid),
|
||||
&p->route[report_pos-1].node_id),
|
||||
style);
|
||||
}
|
||||
}
|
||||
@ -1251,7 +1251,7 @@ handle_intermediate_failure(struct command *cmd,
|
||||
type_to_string(tmpctx, struct node_id, errnode),
|
||||
failcode, onion_wire_name(failcode),
|
||||
type_to_string(tmpctx, struct short_channel_id,
|
||||
&errchan->channel_id),
|
||||
&errchan->scid),
|
||||
p->routetxt);
|
||||
|
||||
/* We use an exhaustive switch statement here so you get a compile
|
||||
@ -1279,7 +1279,7 @@ handle_intermediate_failure(struct command *cmd,
|
||||
case WIRE_UNKNOWN_NEXT_PEER:
|
||||
case WIRE_REQUIRED_CHANNEL_FEATURE_MISSING:
|
||||
/* All of these result in the channel being marked as disabled. */
|
||||
channel_hints_update(root, errchan->channel_id,
|
||||
channel_hints_update(root, errchan->scid,
|
||||
errchan->direction, false, false, NULL,
|
||||
NULL);
|
||||
break;
|
||||
@ -1287,7 +1287,7 @@ handle_intermediate_failure(struct command *cmd,
|
||||
case WIRE_TEMPORARY_CHANNEL_FAILURE: {
|
||||
/* These are an indication that the capacity was insufficient,
|
||||
* remember the amount we tried as an estimate. */
|
||||
channel_hints_update(root, errchan->channel_id,
|
||||
channel_hints_update(root, errchan->scid,
|
||||
errchan->direction, true, false,
|
||||
&errchan->amount, NULL);
|
||||
goto error;
|
||||
@ -1358,7 +1358,7 @@ static bool assign_blame(const struct payment *p,
|
||||
/* Final node *shouldn't* report BADONION, but don't assume. */
|
||||
if (index >= tal_count(p->route)) {
|
||||
*errchan = NULL;
|
||||
*errnode = &p->route[tal_count(p->route) - 1].nodeid;
|
||||
*errnode = &p->route[tal_count(p->route) - 1].node_id;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1366,7 +1366,7 @@ static bool assign_blame(const struct payment *p,
|
||||
if (index == 0)
|
||||
*errnode = p->local_id;
|
||||
else
|
||||
*errnode = &p->route[index - 1].nodeid;
|
||||
*errnode = &p->route[index - 1].node_id;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1547,11 +1547,11 @@ static struct command_result *payment_createonion_success(struct command *cmd,
|
||||
json_add_hex_talarr(req->js, "onion", p->createonion_response->onion);
|
||||
|
||||
json_object_start(req->js, "first_hop");
|
||||
json_add_short_channel_id(req->js, "channel", &first->channel_id);
|
||||
json_add_short_channel_id(req->js, "channel", &first->scid);
|
||||
json_add_num(req->js, "direction", first->direction);
|
||||
json_add_amount_msat_only(req->js, "amount_msat", first->amount);
|
||||
json_add_num(req->js, "delay", first->delay);
|
||||
json_add_node_id(req->js, "id", &first->nodeid);
|
||||
json_add_node_id(req->js, "id", &first->node_id);
|
||||
json_object_end(req->js);
|
||||
|
||||
json_add_sha256(req->js, "payment_hash", p->payment_hash);
|
||||
@ -1616,7 +1616,7 @@ static void payment_add_hop_onion_payload(struct payment *p,
|
||||
dst->style = node->style;
|
||||
if (force_tlv)
|
||||
dst->style = ROUTE_HOP_TLV;
|
||||
dst->pubkey = node->nodeid;
|
||||
dst->pubkey = node->node_id;
|
||||
|
||||
switch (dst->style) {
|
||||
case ROUTE_HOP_LEGACY:
|
||||
@ -1624,7 +1624,7 @@ static void payment_add_hop_onion_payload(struct payment *p,
|
||||
dst->legacy_payload->forward_amt = next->amount;
|
||||
|
||||
if (!final)
|
||||
dst->legacy_payload->scid = next->channel_id;
|
||||
dst->legacy_payload->scid = next->scid;
|
||||
else
|
||||
dst->legacy_payload->scid = all_zero_scid;
|
||||
|
||||
@ -1641,7 +1641,7 @@ static void payment_add_hop_onion_payload(struct payment *p,
|
||||
if (!final)
|
||||
tlvstream_set_short_channel_id(fields,
|
||||
TLV_TLV_PAYLOAD_SHORT_CHANNEL_ID,
|
||||
&next->channel_id);
|
||||
&next->scid);
|
||||
|
||||
if (payment_secret != NULL) {
|
||||
assert(final);
|
||||
@ -1692,7 +1692,7 @@ static void payment_compute_onion_payloads(struct payment *p)
|
||||
NULL);
|
||||
tal_append_fmt(&routetxt, "%s -> ",
|
||||
type_to_string(tmpctx, struct short_channel_id,
|
||||
&p->route[i].channel_id));
|
||||
&p->route[i].scid));
|
||||
}
|
||||
|
||||
/* Final hop */
|
||||
@ -1702,7 +1702,7 @@ static void payment_compute_onion_payloads(struct payment *p)
|
||||
root->payment_secret);
|
||||
tal_append_fmt(&routetxt, "%s",
|
||||
type_to_string(tmpctx, struct short_channel_id,
|
||||
&p->route[hopcount - 1].channel_id));
|
||||
&p->route[hopcount - 1].scid));
|
||||
|
||||
paymod_log(p, LOG_DBG,
|
||||
"Created outgoing onion for route: %s", routetxt);
|
||||
@ -2784,9 +2784,9 @@ static void routehint_step_cb(struct routehints_data *d, struct payment *p)
|
||||
return payment_continue(p);
|
||||
}
|
||||
|
||||
hop.nodeid = *route_pubkey(p, routehint, i + 1);
|
||||
hop.node_id = *route_pubkey(p, routehint, i + 1);
|
||||
hop.style = ROUTE_HOP_LEGACY;
|
||||
hop.channel_id = routehint[i].short_channel_id;
|
||||
hop.scid = routehint[i].short_channel_id;
|
||||
hop.amount = dest_amount;
|
||||
hop.delay = route_cltv(d->final_cltv, routehint + i + 1,
|
||||
tal_count(routehint) - i - 1);
|
||||
@ -2796,7 +2796,7 @@ static void routehint_step_cb(struct routehints_data *d, struct payment *p)
|
||||
* it's rather easy to compute given the two
|
||||
* subsequent hops. */
|
||||
hop.direction =
|
||||
node_id_cmp(&prev_hop->nodeid, &hop.nodeid) > 0 ? 1
|
||||
node_id_cmp(&prev_hop->node_id, &hop.node_id) > 0 ? 1
|
||||
: 0;
|
||||
tal_arr_expand(&p->route, hop);
|
||||
}
|
||||
@ -3166,9 +3166,9 @@ static void direct_pay_override(struct payment *p) {
|
||||
p->route = tal_arr(p, struct route_hop, 1);
|
||||
p->route[0].amount = p->amount;
|
||||
p->route[0].delay = p->getroute->cltv;
|
||||
p->route[0].channel_id = hint->scid.scid;
|
||||
p->route[0].scid = hint->scid.scid;
|
||||
p->route[0].direction = hint->scid.dir;
|
||||
p->route[0].nodeid = *p->destination;
|
||||
p->route[0].node_id = *p->destination;
|
||||
p->route[0].style = p->destination_has_tlv ? ROUTE_HOP_TLV : ROUTE_HOP_LEGACY;
|
||||
paymod_log(p, LOG_DBG,
|
||||
"Found a direct channel (%s) with sufficient "
|
||||
|
@ -1619,8 +1619,8 @@ static bool json_to_route_hop_inplace(struct route_hop *dst, const char *buffer,
|
||||
amounttok == NULL || delaytok == NULL || styletok == NULL)
|
||||
return false;
|
||||
|
||||
json_to_node_id(buffer, idtok, &dst->nodeid);
|
||||
json_to_short_channel_id(buffer, channeltok, &dst->channel_id);
|
||||
json_to_node_id(buffer, idtok, &dst->node_id);
|
||||
json_to_short_channel_id(buffer, channeltok, &dst->scid);
|
||||
json_to_int(buffer, directiontok, &dst->direction);
|
||||
json_to_msat(buffer, amounttok, &dst->amount);
|
||||
json_to_number(buffer, delaytok, &dst->delay);
|
||||
|
@ -346,9 +346,9 @@ enum route_hop_style {
|
||||
};
|
||||
|
||||
struct route_hop {
|
||||
struct short_channel_id channel_id;
|
||||
struct short_channel_id scid;
|
||||
int direction;
|
||||
struct node_id nodeid;
|
||||
struct node_id node_id;
|
||||
struct amount_msat amount;
|
||||
u32 delay;
|
||||
struct pubkey *blinding;
|
||||
|
Loading…
Reference in New Issue
Block a user