This gets all the scids they asked for, and optionally the timestamps and checksums */
| 562 | |
| 563 | /* This gets all the scids they asked for, and optionally the timestamps and checksums */ |
| 564 | static struct short_channel_id *gather_range(const tal_t *ctx, |
| 565 | struct daemon *daemon, |
| 566 | u32 first_blocknum, u32 number_of_blocks, |
| 567 | enum query_option_flags query_option_flags, |
| 568 | struct channel_update_timestamps **tstamps, |
| 569 | struct channel_update_checksums **csums) |
| 570 | { |
| 571 | struct short_channel_id *scids; |
| 572 | u32 end_block; |
| 573 | struct gossmap *gossmap = get_gossmap(daemon); |
| 574 | |
| 575 | scids = tal_arr(ctx, struct short_channel_id, 0); |
| 576 | if (query_option_flags & QUERY_ADD_TIMESTAMPS) |
| 577 | *tstamps = tal_arr(ctx, struct channel_update_timestamps, 0); |
| 578 | else |
| 579 | *tstamps = NULL; |
| 580 | if (query_option_flags & QUERY_ADD_CHECKSUMS) |
| 581 | *csums = tal_arr(ctx, struct channel_update_checksums, 0); |
| 582 | else |
| 583 | *csums = NULL; |
| 584 | |
| 585 | if (number_of_blocks == 0) |
| 586 | return NULL; |
| 587 | |
| 588 | /* Fix up number_of_blocks to avoid overflow. */ |
| 589 | end_block = first_blocknum + number_of_blocks - 1; |
| 590 | if (end_block < first_blocknum) |
| 591 | end_block = UINT_MAX; |
| 592 | |
| 593 | /* We used to maintain a uintmap of channels by scid, but |
| 594 | * we no longer do, making this more expensive. But still |
| 595 | * not too bad, since it's usually in-mem */ |
| 596 | for (size_t i = 0; i < gossmap_max_chan_idx(gossmap); i++) { |
| 597 | struct gossmap_chan *chan = gossmap_chan_byidx(gossmap, i); |
| 598 | struct short_channel_id scid; |
| 599 | |
| 600 | if (!chan) |
| 601 | continue; |
| 602 | |
| 603 | /* By policy, we don't give announcements here with no |
| 604 | * channel_updates */ |
| 605 | if (!gossmap_chan_set(chan, 0) && !gossmap_chan_set(chan, 1)) { |
| 606 | continue; |
| 607 | } |
| 608 | |
| 609 | scid = gossmap_chan_scid(gossmap, chan); |
| 610 | if (short_channel_id_blocknum(scid) < first_blocknum |
| 611 | || short_channel_id_blocknum(scid) > end_block) { |
| 612 | continue; |
| 613 | } |
| 614 | |
| 615 | tal_arr_expand(&scids, scid); |
| 616 | |
| 617 | if (*tstamps) { |
| 618 | struct channel_update_timestamps ts; |
| 619 | |
| 620 | ts.timestamp_node_id_1 = get_timestamp(gossmap, chan, 0); |
| 621 | ts.timestamp_node_id_2 = get_timestamp(gossmap, chan, 1); |
no test coverage detected