~ This is the reply we get when we send query_channel_range; we keep * expecting them until the entire range we asked for is covered. */
| 181 | /*~ This is the reply we get when we send query_channel_range; we keep |
| 182 | * expecting them until the entire range we asked for is covered. */ |
| 183 | const u8 *handle_reply_channel_range(struct peer *peer, const u8 *msg) |
| 184 | { |
| 185 | struct bitcoin_blkid chain; |
| 186 | u8 sync_complete; |
| 187 | u32 first_blocknum, number_of_blocks, start, end; |
| 188 | u8 *encoded; |
| 189 | struct short_channel_id *scids; |
| 190 | const struct range_query_reply *replies; |
| 191 | const u8 *err; |
| 192 | void (*cb)(struct peer *peer, |
| 193 | u32 first_blocknum, u32 number_of_blocks, |
| 194 | const struct range_query_reply *replies); |
| 195 | struct tlv_reply_channel_range_tlvs *tlvs; |
| 196 | |
| 197 | if (!fromwire_reply_channel_range(tmpctx, msg, &chain, &first_blocknum, |
| 198 | &number_of_blocks, &sync_complete, |
| 199 | &encoded, &tlvs)) { |
| 200 | return towire_warningfmt(peer, NULL, |
| 201 | "Bad reply_channel_range w/tlvs %s", |
| 202 | tal_hex(tmpctx, msg)); |
| 203 | } |
| 204 | |
| 205 | if (!bitcoin_blkid_eq(&chainparams->genesis_blockhash, &chain)) { |
| 206 | return towire_warningfmt(peer, NULL, |
| 207 | "reply_channel_range for bad chain: %s", |
| 208 | tal_hex(tmpctx, msg)); |
| 209 | } |
| 210 | |
| 211 | if (!peer->range_replies) { |
| 212 | return towire_warningfmt(peer, NULL, |
| 213 | "reply_channel_range without query: %s", |
| 214 | tal_hex(tmpctx, msg)); |
| 215 | } |
| 216 | |
| 217 | /* Beware overflow! */ |
| 218 | if (first_blocknum + number_of_blocks < first_blocknum) { |
| 219 | return towire_warningfmt(peer, NULL, |
| 220 | "reply_channel_range invalid %u+%u", |
| 221 | first_blocknum, number_of_blocks); |
| 222 | } |
| 223 | |
| 224 | scids = decode_short_ids(tmpctx, encoded); |
| 225 | if (!scids) { |
| 226 | return towire_warningfmt(peer, NULL, |
| 227 | "Bad reply_channel_range encoding %s", |
| 228 | tal_hex(tmpctx, encoded)); |
| 229 | } |
| 230 | |
| 231 | status_peer_debug(&peer->id, |
| 232 | "reply_channel_range %u+%u (of %u+%u) %zu scids", |
| 233 | first_blocknum, number_of_blocks, |
| 234 | peer->range_first_blocknum, |
| 235 | peer->range_end_blocknum - peer->range_first_blocknum, |
| 236 | tal_count(scids)); |
| 237 | |
| 238 | /* BOLT #7: |
| 239 | * The receiver of `query_channel_range`: |
| 240 | *... |
no test coverage detected