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

Function process_node_announcement

gossipd/gossmap_manage.c:1171–1219  ·  view source on GitHub ↗

This is called both from when we receive the node announcement, and if we had to defer. */

Source from the content-addressed store, hash-verified

1169
1170/* This is called both from when we receive the node announcement, and if we had to defer. */
1171static const char *process_node_announcement(const tal_t *ctx,
1172 struct gossmap_manage *gm,
1173 struct gossmap *gossmap,
1174 const struct gossmap_node *node,
1175 const secp256k1_ecdsa_signature *signature,
1176 u32 timestamp,
1177 const struct node_id *node_id,
1178 const u8 *nannounce,
1179 const struct node_id *source_peer)
1180{
1181 u64 offset;
1182 const char *err;
1183
1184 /* Do we have a later one? If so, ignore */
1185 if (gossmap_node_announced(node)) {
1186 u32 prev_timestamp
1187 = gossip_store_get_timestamp(gm->gs, node->nann_off);
1188 if (prev_timestamp >= timestamp) {
1189 /* Too old, ignore */
1190 return NULL;
1191 }
1192 }
1193
1194 /* only now do the (expensive) signature check */
1195 err = sigcheck_node_announcement(ctx, node_id, signature, nannounce);
1196 if (err)
1197 return err;
1198
1199 /* OK, apply the new one */
1200 offset = gossip_store_add(gm->gs, nannounce, timestamp);
1201 /* If all channels are dying, make sure this is marked too. */
1202 if (all_node_channels_dying(gossmap, node, NULL)) {
1203 gossip_store_set_flag(gm->gs, offset,
1204 GOSSIP_STORE_DYING_BIT,
1205 WIRE_NODE_ANNOUNCEMENT);
1206 }
1207
1208 /* Now delete old */
1209 if (gossmap_node_announced(node))
1210 gossip_store_del(gm->gs, node->nann_off, WIRE_NODE_ANNOUNCEMENT);
1211
1212 /* Used to evaluate gossip peers' performance */
1213 peer_supplied_good_gossip(gm->daemon, source_peer, 1);
1214
1215 status_peer_trace(source_peer,
1216 "Received node_announcement for node %s",
1217 fmt_node_id(tmpctx, node_id));
1218 return NULL;
1219}
1220
1221const char *gossmap_manage_node_announcement(const tal_t *ctx,
1222 struct gossmap_manage *gm,

Callers 2

reprocess_queued_msgsFunction · 0.85

Calls 9

gossmap_node_announcedFunction · 0.85
gossip_store_addFunction · 0.85
all_node_channels_dyingFunction · 0.85
gossip_store_set_flagFunction · 0.85
gossip_store_delFunction · 0.85
fmt_node_idFunction · 0.85

Tested by

no test coverage detected