Based on existing update, schedule next refresh */
| 591 | |
| 592 | /* Based on existing update, schedule next refresh */ |
| 593 | static void arm_refresh_timer(struct channel *channel) |
| 594 | { |
| 595 | struct lightningd *ld = channel->peer->ld; |
| 596 | struct channel_gossip *cg = channel->channel_gossip; |
| 597 | struct timeabs now = clock_time(), due; |
| 598 | u32 timestamp; |
| 599 | |
| 600 | if (!channel_update_details(cg->cupdate, ×tamp, NULL)) { |
| 601 | log_broken(channel->log, "Missing channel_update for refresh?"); |
| 602 | return; |
| 603 | } |
| 604 | due.ts.tv_sec = timestamp; |
| 605 | due.ts.tv_nsec = 0; |
| 606 | |
| 607 | due = timeabs_add(due, |
| 608 | time_from_sec(GOSSIP_PRUNE_INTERVAL(ld->dev_fast_gossip_prune) |
| 609 | - GOSSIP_BEFORE_DEADLINE(ld->dev_fast_gossip_prune))); |
| 610 | |
| 611 | /* In case it's passed, timer should be zero */ |
| 612 | if (time_after(now, due)) |
| 613 | due = now; |
| 614 | |
| 615 | cg->refresh_timer = new_reltimer(ld->timers, cg, |
| 616 | time_between(due, now), |
| 617 | cupdate_timer_refresh, |
| 618 | channel); |
| 619 | } |
| 620 | |
| 621 | static void cupdate_timer_refresh(struct channel *channel) |
| 622 | { |
no test coverage detected