~ The peer can ask for all channels in a series of blocks. We reply with one * or more messages containing the short_channel_ids. */
| 571 | /*~ The peer can ask for all channels in a series of blocks. We reply with one |
| 572 | * or more messages containing the short_channel_ids. */ |
| 573 | const u8 *handle_query_channel_range(struct peer *peer, const u8 *msg) |
| 574 | { |
| 575 | struct bitcoin_blkid chain_hash; |
| 576 | u32 first_blocknum, number_of_blocks; |
| 577 | enum query_option_flags query_option_flags; |
| 578 | struct tlv_query_channel_range_tlvs *tlvs; |
| 579 | |
| 580 | if (!fromwire_query_channel_range(msg, msg, &chain_hash, |
| 581 | &first_blocknum, &number_of_blocks, |
| 582 | &tlvs)) { |
| 583 | return towire_warningfmt(peer, NULL, |
| 584 | "Bad query_channel_range w/tlvs %s", |
| 585 | tal_hex(tmpctx, msg)); |
| 586 | } |
| 587 | if (tlvs->query_option) |
| 588 | query_option_flags = *tlvs->query_option; |
| 589 | else |
| 590 | query_option_flags = 0; |
| 591 | |
| 592 | /* BOLT #7 |
| 593 | * |
| 594 | * The receiver of `query_channel_range`: |
| 595 | * ... |
| 596 | * - if does not maintain up-to-date channel information for `chain_hash`: |
| 597 | * - MUST set `complete` to 0. |
| 598 | */ |
| 599 | if (!bitcoin_blkid_eq(&chainparams->genesis_blockhash, &chain_hash)) { |
| 600 | status_peer_debug(&peer->id, |
| 601 | "query_channel_range with chainhash %s", |
| 602 | type_to_string(tmpctx, struct bitcoin_blkid, |
| 603 | &chain_hash)); |
| 604 | u8 *end = towire_reply_channel_range(NULL, &chain_hash, first_blocknum, |
| 605 | number_of_blocks, false, NULL, NULL); |
| 606 | queue_peer_msg(peer, take(end)); |
| 607 | return NULL; |
| 608 | } |
| 609 | |
| 610 | /* Fix up number_of_blocks to avoid overflow. */ |
| 611 | if (first_blocknum + number_of_blocks < first_blocknum) |
| 612 | number_of_blocks = UINT_MAX - first_blocknum; |
| 613 | |
| 614 | queue_channel_ranges(peer, first_blocknum, number_of_blocks, |
| 615 | query_option_flags); |
| 616 | return NULL; |
| 617 | } |
| 618 | |
| 619 | /* Append these scids (and optional timestamps) to our pending replies */ |
| 620 | static u8 *append_range_reply(struct peer *peer, |
no test coverage detected