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

Function update_own_node_announcement

gossipd/gossip_generation.c:252–331  ·  view source on GitHub ↗

This routine created a `node_announcement` for our node, and hands it to * the routing.c code like any other `node_announcement`. Such announcements * are only accepted if there is an announced channel associated with that node * (to prevent spam), so we only call this once we've announced a channel. */ Returns true if this sent one, or has arranged to send one in future. */

Source from the content-addressed store, hash-verified

250 * (to prevent spam), so we only call this once we've announced a channel. */
251/* Returns true if this sent one, or has arranged to send one in future. */
252static bool update_own_node_announcement(struct daemon *daemon,
253 bool startup,
254 bool always_refresh)
255{
256 u32 timestamp = gossip_time_now(daemon->rstate).ts.tv_sec;
257 u8 *nannounce;
258 struct node *self = get_node(daemon->rstate, &daemon->id);
259
260 /* Discard existing timer. */
261 daemon->node_announce_timer = tal_free(daemon->node_announce_timer);
262
263 /* If we ever use set-based propagation, ensuring the toggle the lower
264 * bit in consecutive timestamps makes it more robust. */
265 if (self && self->bcast.index
266 && (timestamp & 1) == (self->bcast.timestamp & 1))
267 timestamp++;
268
269 /* Make unsigned announcement. */
270 nannounce = create_node_announcement(tmpctx, daemon, NULL,
271 timestamp,
272 daemon->rates);
273
274 /* If it's the same as the previous, nothing to do. */
275 if (self && self->bcast.index) {
276 u32 next;
277 bool only_missing_tlv;
278
279 if (!nannounce_different(daemon->rstate->gs, self, nannounce,
280 &only_missing_tlv)) {
281 if (always_refresh)
282 goto send;
283 return false;
284 }
285
286 /* Missing liquidity_ad, maybe we'll get plugin callback */
287 if (startup && only_missing_tlv) {
288 u32 delay = GOSSIP_NANN_STARTUP_DELAY(daemon->rstate->dev_fast_gossip);
289 status_debug("node_announcement: delaying"
290 " %u secs at start", delay);
291
292 daemon->node_announce_timer
293 = new_reltimer(&daemon->timers,
294 daemon,
295 time_from_sec(delay),
296 update_own_node_announcement_after_startup,
297 daemon);
298 return true;
299 }
300 /* BOLT #7:
301 *
302 * The origin node:
303 * - MUST set `timestamp` to be greater than that of any
304 * previous `node_announcement` it has previously created.
305 */
306 /* We do better: never send them within more than 5 minutes. */
307 next = self->bcast.timestamp
308 + GOSSIP_MIN_INTERVAL(daemon->rstate->dev_fast_gossip);
309

Calls 8

tal_freeFunction · 0.85
create_node_announcementFunction · 0.85
time_from_secFunction · 0.85
sign_and_send_nannounceFunction · 0.85
gossip_time_nowFunction · 0.70
get_nodeFunction · 0.70
nannounce_differentFunction · 0.70

Tested by

no test coverage detected