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

Function timestamp_for_update

gossipd/gossip_generation.c:429–453  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

427
428
429static u32 timestamp_for_update(struct daemon *daemon,
430 const u32 *prev_timestamp,
431 bool disable)
432{
433 u32 timestamp = gossip_time_now(daemon->rstate).ts.tv_sec;
434
435 /* Create an unsigned channel_update: we backdate enables, so
436 * we can always send a disable in an emergency. */
437 if (!disable)
438 timestamp -= GOSSIP_MIN_INTERVAL(daemon->rstate->dev_fast_gossip);
439
440 if (prev_timestamp) {
441 /* Timestamps can't go backwards! */
442 if (timestamp < *prev_timestamp)
443 timestamp = *prev_timestamp + 1;
444
445 /* If we ever use set-based propagation, ensuring the toggle
446 * the lower bit in consecutive timestamps makes it more
447 * robust. */
448 if ((timestamp & 1) == (*prev_timestamp & 1))
449 timestamp++;
450 }
451
452 return timestamp;
453}
454
455static u8 *sign_and_timestamp_update(const tal_t *ctx,
456 struct daemon *daemon,

Callers 1

Calls 1

gossip_time_nowFunction · 0.70

Tested by

no test coverage detected