~ The peer can ask for all channels in a series of blocks. We reply with one * or more messages containing the short_channel_ids. */
| 713 | /*~ The peer can ask for all channels in a series of blocks. We reply with one |
| 714 | * or more messages containing the short_channel_ids. */ |
| 715 | void handle_query_channel_range(struct peer *peer, const u8 *msg) |
| 716 | { |
| 717 | struct bitcoin_blkid chain_hash; |
| 718 | u32 first_blocknum, number_of_blocks; |
| 719 | enum query_option_flags query_option_flags; |
| 720 | struct tlv_query_channel_range_tlvs *tlvs; |
| 721 | |
| 722 | if (!fromwire_query_channel_range(msg, msg, &chain_hash, |
| 723 | &first_blocknum, &number_of_blocks, |
| 724 | &tlvs)) { |
| 725 | warning_to_peer(peer, |
| 726 | "Bad query_channel_range w/tlvs %s", |
| 727 | tal_hex(tmpctx, msg)); |
| 728 | return; |
| 729 | } |
| 730 | if (tlvs->query_option) |
| 731 | query_option_flags = *tlvs->query_option; |
| 732 | else |
| 733 | query_option_flags = 0; |
| 734 | |
| 735 | /* Unknown chain_hash: reply with sync_complete=false. */ |
| 736 | if (!bitcoin_blkid_eq(&chainparams->genesis_blockhash, &chain_hash)) { |
| 737 | status_peer_debug(&peer->id, |
| 738 | "query_channel_range with chainhash %s", |
| 739 | fmt_bitcoin_blkid(tmpctx, &chain_hash)); |
| 740 | u8 *end = towire_reply_channel_range(NULL, &chain_hash, first_blocknum, |
| 741 | number_of_blocks, false, NULL, NULL); |
| 742 | inject_peer_msg(peer, take(end)); |
| 743 | return; |
| 744 | } |
| 745 | |
| 746 | /* Fix up number_of_blocks to avoid overflow. */ |
| 747 | if (first_blocknum + number_of_blocks < first_blocknum) |
| 748 | number_of_blocks = UINT_MAX - first_blocknum; |
| 749 | |
| 750 | queue_channel_ranges(peer, first_blocknum, number_of_blocks, |
| 751 | query_option_flags); |
| 752 | } |
| 753 | |
| 754 | /* This is a testing hack to allow us to artificially lower the maximum bytes |
| 755 | * of short_channel_ids we'll encode, using dev_set_max_scids_encode_size. */ |
no test coverage detected