~ We can send multiple replies when the peer queries for all channels in * a given range of blocks; each one indicates the range of blocks it covers. */
| 273 | /*~ We can send multiple replies when the peer queries for all channels in |
| 274 | * a given range of blocks; each one indicates the range of blocks it covers. */ |
| 275 | static void send_reply_channel_range(struct peer *peer, |
| 276 | u32 first_blocknum, u32 number_of_blocks, |
| 277 | const struct short_channel_id *scids, |
| 278 | const struct channel_update_timestamps *tstamps, |
| 279 | const struct channel_update_checksums *csums, |
| 280 | size_t num_scids, |
| 281 | bool final) |
| 282 | { |
| 283 | /* BOLT #7: |
| 284 | * |
| 285 | * - MUST respond with one or more `reply_channel_range`: |
| 286 | * - MUST set with `chain_hash` equal to that of `query_channel_range`, |
| 287 | * - MUST limit `number_of_blocks` to the maximum number of blocks |
| 288 | * whose results could fit in `encoded_short_ids` |
| 289 | */ |
| 290 | u8 *encoded_scids = encoding_start(tmpctx, true); |
| 291 | u8 *encoded_timestamps = encoding_start(tmpctx, false); |
| 292 | struct tlv_reply_channel_range_tlvs *tlvs |
| 293 | = tlv_reply_channel_range_tlvs_new(tmpctx); |
| 294 | |
| 295 | /* Encode them all */ |
| 296 | for (size_t i = 0; i < num_scids; i++) |
| 297 | encoding_add_short_channel_id(&encoded_scids, &scids[i]); |
| 298 | encoding_end(encoded_scids, tal_bytelen(encoded_scids)); |
| 299 | |
| 300 | if (tstamps) { |
| 301 | for (size_t i = 0; i < num_scids; i++) |
| 302 | encoding_add_timestamps(&encoded_timestamps, &tstamps[i]); |
| 303 | |
| 304 | tlvs->timestamps_tlv = tal(tlvs, struct tlv_reply_channel_range_tlvs_timestamps_tlv); |
| 305 | tlvs->timestamps_tlv->encoding_type = ARR_UNCOMPRESSED; |
| 306 | encoding_end(encoded_timestamps, |
| 307 | tal_bytelen(encoded_timestamps)); |
| 308 | tlvs->timestamps_tlv->encoded_timestamps |
| 309 | = tal_steal(tlvs, encoded_timestamps); |
| 310 | } |
| 311 | |
| 312 | /* Must be a tal object! */ |
| 313 | if (csums) |
| 314 | tlvs->checksums_tlv = tal_dup_arr(tlvs, |
| 315 | struct channel_update_checksums, |
| 316 | csums, num_scids, 0); |
| 317 | |
| 318 | /* BOLT #7: |
| 319 | * |
| 320 | * - MUST set `sync_complete` to `false` if this is not the final |
| 321 | * `reply_channel_range`. |
| 322 | */ |
| 323 | u8 *msg = towire_reply_channel_range(NULL, |
| 324 | &chainparams->genesis_blockhash, |
| 325 | first_blocknum, |
| 326 | number_of_blocks, |
| 327 | final, encoded_scids, tlvs); |
| 328 | queue_peer_msg(peer, take(msg)); |
| 329 | } |
| 330 | |
| 331 | /* BOLT #7: |
| 332 | * |
no test coverage detected