| 427 | |
| 428 | |
| 429 | static 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 | |
| 455 | static u8 *sign_and_timestamp_update(const tal_t *ctx, |
| 456 | struct daemon *daemon, |
no test coverage detected