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

Function process_node_announcement

gossipd/gossmap_manage.c:1122–1161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1120}
1121
1122static void process_node_announcement(struct gossmap_manage *gm,
1123 struct gossmap *gossmap,
1124 const struct gossmap_node *node,
1125 u32 timestamp,
1126 const struct node_id *node_id,
1127 const u8 *nannounce,
1128 const struct node_id *source_peer)
1129{
1130 u64 offset;
1131
1132 /* Do we have a later one? If so, ignore */
1133 if (gossmap_node_announced(node)) {
1134 u32 prev_timestamp
1135 = gossip_store_get_timestamp(gm->gs, node->nann_off);
1136 if (prev_timestamp >= timestamp) {
1137 /* Too old, ignore */
1138 return;
1139 }
1140 }
1141
1142 /* OK, apply the new one */
1143 offset = gossip_store_add(gm->gs, nannounce, timestamp);
1144 /* If all channels are dying, make sure this is marked too. */
1145 if (all_node_channels_dying(gossmap, node, NULL)) {
1146 gossip_store_set_flag(gm->gs, offset,
1147 GOSSIP_STORE_DYING_BIT,
1148 WIRE_NODE_ANNOUNCEMENT);
1149 }
1150
1151 /* Now delete old */
1152 if (gossmap_node_announced(node))
1153 gossip_store_del(gm->gs, node->nann_off, WIRE_NODE_ANNOUNCEMENT);
1154
1155 /* Used to evaluate gossip peers' performance */
1156 peer_supplied_good_gossip(gm->daemon, source_peer, 1);
1157
1158 status_peer_trace(source_peer,
1159 "Received node_announcement for node %s",
1160 fmt_node_id(tmpctx, node_id));
1161}
1162
1163const char *gossmap_manage_node_announcement(const tal_t *ctx,
1164 struct gossmap_manage *gm,

Callers 2

reprocess_queued_msgsFunction · 0.85

Calls 8

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