mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-03 06:14:30 +01:00
gossipd: add hop-style to nodes to mark whether they speak TLV onion.
We keep the feature bitmap on disk, so we cache this in the struct explicitly. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
2a2259083a
commit
3a25e9b8d6
@@ -380,6 +380,8 @@ static struct node *new_node(struct routing_state *rstate,
|
||||
n->id = *id;
|
||||
memset(n->chans.arr, 0, sizeof(n->chans.arr));
|
||||
broadcastable_init(&n->bcast);
|
||||
/* We don't know, so assume legacy. */
|
||||
n->hop_style = ROUTE_HOP_LEGACY;
|
||||
n->tokens = TOKEN_MAX;
|
||||
node_map_add(rstate->nodes, n);
|
||||
tal_add_destructor2(n, destroy_node, rstate);
|
||||
@@ -2510,6 +2512,12 @@ bool routing_add_node_announcement(struct routing_state *rstate,
|
||||
&& node->bcast.timestamp < time_now().ts.tv_sec)
|
||||
rstate->last_timestamp = node->bcast.timestamp;
|
||||
|
||||
if (feature_offered(features, OPT_VAR_ONION))
|
||||
node->hop_style = ROUTE_HOP_TLV;
|
||||
else
|
||||
/* Reset it in case they no longer offer the feature */
|
||||
node->hop_style = ROUTE_HOP_LEGACY;
|
||||
|
||||
if (index)
|
||||
node->bcast.index = index;
|
||||
else {
|
||||
@@ -2707,6 +2715,7 @@ struct route_hop *get_route(const tal_t *ctx, struct routing_state *rstate,
|
||||
hops[i].amount = total_amount;
|
||||
hops[i].delay = total_delay;
|
||||
hops[i].direction = idx;
|
||||
hops[i].style = n->hop_style;
|
||||
|
||||
/* Since we calculated this route, it should not overflow! */
|
||||
if (!amount_msat_add_fee(&total_amount,
|
||||
|
||||
@@ -133,6 +133,11 @@ HTABLE_DEFINE_TYPE(struct local_chan,
|
||||
local_chan_map_scid, hash_scid, local_chan_eq_scid,
|
||||
local_chan_map);
|
||||
|
||||
enum route_hop_style {
|
||||
ROUTE_HOP_LEGACY = 1,
|
||||
ROUTE_HOP_TLV = 2,
|
||||
};
|
||||
|
||||
/* For a small number of channels (by far the most common) we use a simple
|
||||
* array, with empty buckets NULL. For larger, we use a proper hash table,
|
||||
* with the extra allocation that implies. */
|
||||
@@ -147,6 +152,9 @@ struct node {
|
||||
/* Token bucket */
|
||||
u8 tokens;
|
||||
|
||||
/* route_hop_style */
|
||||
enum route_hop_style hop_style;
|
||||
|
||||
/* Channels connecting us to other nodes */
|
||||
union {
|
||||
struct chan_map map;
|
||||
@@ -320,6 +328,7 @@ struct route_hop {
|
||||
struct node_id nodeid;
|
||||
struct amount_msat amount;
|
||||
u32 delay;
|
||||
enum route_hop_style style;
|
||||
};
|
||||
|
||||
enum exclude_entry_type {
|
||||
|
||||
@@ -66,6 +66,7 @@ void fromwire_route_hop(const u8 **pptr, size_t *max, struct route_hop *entry)
|
||||
entry->direction = fromwire_u8(pptr, max);
|
||||
entry->amount = fromwire_amount_msat(pptr, max);
|
||||
entry->delay = fromwire_u32(pptr, max);
|
||||
entry->style = fromwire_u8(pptr, max);
|
||||
}
|
||||
|
||||
void towire_route_hop(u8 **pptr, const struct route_hop *entry)
|
||||
@@ -75,6 +76,7 @@ void towire_route_hop(u8 **pptr, const struct route_hop *entry)
|
||||
towire_u8(pptr, entry->direction);
|
||||
towire_amount_msat(pptr, entry->amount);
|
||||
towire_u32(pptr, entry->delay);
|
||||
towire_u8(pptr, entry->style);
|
||||
}
|
||||
|
||||
void fromwire_route_info(const u8 **pptr, size_t *max, struct route_info *entry)
|
||||
|
||||
Reference in New Issue
Block a user