MCPcopy Create free account
hub / github.com/ElementsProject/lightning / get_node_announcement

Function get_node_announcement

gossipd/gossipd.c:135–185  ·  view source on GitHub ↗

~ We don't actually keep node_announcements in memory; we keep them in * a file called `gossip_store`. If we need some node details, we reload * and reparse. It's slow, but generally rare. */

Source from the content-addressed store, hash-verified

133 * a file called `gossip_store`. If we need some node details, we reload
134 * and reparse. It's slow, but generally rare. */
135static bool get_node_announcement(const tal_t *ctx,
136 struct daemon *daemon,
137 const struct node *n,
138 u8 rgb_color[3],
139 u8 alias[32],
140 u8 **features,
141 struct wireaddr **wireaddrs,
142 struct lease_rates **rates)
143{
144 const u8 *msg;
145 struct node_id id;
146 secp256k1_ecdsa_signature signature;
147 u32 timestamp;
148 u8 *addresses;
149 struct tlv_node_ann_tlvs *na_tlvs;
150
151 if (!n->bcast.index)
152 return false;
153
154 msg = gossip_store_get(tmpctx, daemon->rstate->gs, n->bcast.index);
155
156 /* Note: validity of node_id is already checked. */
157 if (!fromwire_node_announcement(ctx, msg,
158 &signature, features,
159 &timestamp,
160 &id, rgb_color, alias,
161 &addresses,
162 &na_tlvs)) {
163 status_broken("Bad local node_announcement @%u: %s",
164 n->bcast.index, tal_hex(tmpctx, msg));
165 return false;
166 }
167
168 if (!node_id_eq(&id, &n->id) || timestamp != n->bcast.timestamp) {
169 status_broken("Wrong node_announcement @%u:"
170 " expected %s timestamp %u "
171 " got %s timestamp %u",
172 n->bcast.index,
173 type_to_string(tmpctx, struct node_id, &n->id),
174 timestamp,
175 type_to_string(tmpctx, struct node_id, &id),
176 n->bcast.timestamp);
177 return false;
178 }
179
180 *wireaddrs = fromwire_wireaddr_array(ctx, addresses);
181 *rates = tal_steal(ctx, na_tlvs->option_will_fund);
182
183 tal_free(addresses);
184 return true;
185}
186
187/* Version which also does nodeid lookup */
188static bool get_node_announcement_by_id(const tal_t *ctx,

Callers 1

Calls 6

tal_hexFunction · 0.85
node_id_eqFunction · 0.85
fromwire_wireaddr_arrayFunction · 0.85
tal_freeFunction · 0.85
gossip_store_getFunction · 0.70
type_to_stringClass · 0.50

Tested by

no test coverage detected