diff --git a/gossipd/routing.c b/gossipd/routing.c index ecbab127d..c571f0ad3 100644 --- a/gossipd/routing.c +++ b/gossipd/routing.c @@ -93,6 +93,8 @@ HTABLE_DEFINE_TYPE(struct pending_node_announce, pending_node_announce_keyof, struct unupdated_channel { /* The channel_announcement message */ const u8 *channel_announce; + /* The feature bitmap within it */ + const u8 *features; /* The short_channel_id */ struct short_channel_id scid; /* The ids of the nodes */ @@ -571,7 +573,8 @@ struct chan *new_chan(struct routing_state *rstate, const struct short_channel_id *scid, const struct node_id *id1, const struct node_id *id2, - struct amount_sat satoshis) + struct amount_sat satoshis, + const u8 *features) { struct chan *chan = tal(rstate, struct chan); int n1idx = node_id_idx(id1, id2); @@ -606,6 +609,8 @@ struct chan *new_chan(struct routing_state *rstate, init_half_chan(rstate, chan, n1idx); init_half_chan(rstate, chan, !n1idx); + /* Stash hint here about whether we have features */ + chan->half[0].any_features = tal_bytelen(features) != 0; uintmap_add(&rstate->chanmap, scid->u64, chan); /* Initialize shadow structure if it's local */ @@ -1651,6 +1656,7 @@ bool routing_add_channel_announcement(struct routing_state *rstate, uc = tal(rstate, struct unupdated_channel); uc->channel_announce = tal_dup_talarr(uc, u8, msg); + uc->features = tal_steal(uc, features); uc->added = gossip_time_now(rstate); uc->index = index; uc->sat = sat; @@ -2098,7 +2104,7 @@ bool routing_add_channel_update(struct routing_state *rstate, if (uc) { assert(!chan); chan = new_chan(rstate, &short_channel_id, - &uc->id[0], &uc->id[1], sat); + &uc->id[0], &uc->id[1], sat, uc->features); } /* Discard older updates */ @@ -2926,7 +2932,8 @@ bool handle_local_add_channel(struct routing_state *rstate, type_to_string(tmpctx, struct short_channel_id, &scid)); /* Create new (unannounced) channel */ - chan = new_chan(rstate, &scid, &rstate->local_id, &remote_node_id, sat); + chan = new_chan(rstate, &scid, &rstate->local_id, &remote_node_id, sat, + features); if (!index) index = gossip_store_add(rstate->gs, msg, 0, false, NULL); chan->bcast.index = index; diff --git a/gossipd/routing.h b/gossipd/routing.h index 33e461891..3e3eb1b4e 100644 --- a/gossipd/routing.h +++ b/gossipd/routing.h @@ -41,6 +41,10 @@ struct half_chan { /* Token bucket */ u8 tokens; + /* Feature cache for parent chan: squeezed in here where it would + * otherwise simply be padding. */ + u8 any_features; + /* Minimum and maximum number of msatoshi in an HTLC */ struct amount_msat htlc_minimum, htlc_maximum; }; @@ -361,7 +365,8 @@ struct chan *new_chan(struct routing_state *rstate, const struct short_channel_id *scid, const struct node_id *id1, const struct node_id *id2, - struct amount_sat sat); + struct amount_sat sat, + const u8 *features); /* Handlers for incoming messages */ diff --git a/gossipd/test/run-bench-find_route.c b/gossipd/test/run-bench-find_route.c index 87d757213..89c26b483 100644 --- a/gossipd/test/run-bench-find_route.c +++ b/gossipd/test/run-bench-find_route.c @@ -149,7 +149,7 @@ static void add_connection(struct routing_state *rstate, chan = get_channel(rstate, &scid); if (!chan) { chan = new_chan(rstate, &scid, &nodes[from], &nodes[to], - AMOUNT_SAT(1000000)); + AMOUNT_SAT(1000000), NULL); } c = &chan->half[idx]; diff --git a/gossipd/test/run-find_route-specific.c b/gossipd/test/run-find_route-specific.c index 954a5647a..3eaf9dd80 100644 --- a/gossipd/test/run-find_route-specific.c +++ b/gossipd/test/run-find_route-specific.c @@ -134,7 +134,7 @@ get_or_make_connection(struct routing_state *rstate, abort(); chan = get_channel(rstate, &scid); if (!chan) - chan = new_chan(rstate, &scid, from_id, to_id, satoshis); + chan = new_chan(rstate, &scid, from_id, to_id, satoshis, NULL); /* Make sure it's seen as initialized (index non-zero). */ chan->half[idx].bcast.index = 1; diff --git a/gossipd/test/run-find_route.c b/gossipd/test/run-find_route.c index 811bed55e..513e42df3 100644 --- a/gossipd/test/run-find_route.c +++ b/gossipd/test/run-find_route.c @@ -142,7 +142,7 @@ static void add_connection(struct routing_state *rstate, chan = get_channel(rstate, &scid); if (!chan) - chan = new_chan(rstate, &scid, from, to, satoshis); + chan = new_chan(rstate, &scid, from, to, satoshis, NULL); c = &chan->half[node_id_idx(from, to)]; /* Make sure it's seen as initialized (index non-zero). */ diff --git a/gossipd/test/run-overlong.c b/gossipd/test/run-overlong.c index e730d9f41..262f70d9c 100644 --- a/gossipd/test/run-overlong.c +++ b/gossipd/test/run-overlong.c @@ -163,7 +163,7 @@ int main(void) if (!mk_short_channel_id(&scid, i, i-1, 0)) abort(); chan = new_chan(rstate, &scid, &ids[i], &ids[i-1], - AMOUNT_SAT(1000000)); + AMOUNT_SAT(1000000), NULL); hc = &chan->half[node_id_idx(&ids[i-1], &ids[i])]; hc->bcast.index = 1; @@ -183,7 +183,7 @@ int main(void) if (!mk_short_channel_id(&scid, i, 1, 0)) abort(); chan = new_chan(rstate, &scid, &ids[i], &ids[1], - AMOUNT_SAT(1000000)); + AMOUNT_SAT(1000000), NULL); hc = &chan->half[node_id_idx(&ids[1], &ids[i])]; hc->bcast.index = 1; hc->base_fee = 1 << i;