MCPcopy Create free account
hub / github.com/ElementsProject/lightning / append_range_reply

Function append_range_reply

gossipd/queries.c:620–657  ·  view source on GitHub ↗

Append these scids (and optional timestamps) to our pending replies */

Source from the content-addressed store, hash-verified

618
619/* Append these scids (and optional timestamps) to our pending replies */
620static u8 *append_range_reply(struct peer *peer,
621 const struct short_channel_id *scids,
622 const struct tlv_reply_channel_range_tlvs_timestamps_tlv
623 *timestamps_tlv)
624{
625 u16 i, old_num, added;
626 const struct channel_update_timestamps *ts;
627 /* Zero means "no timestamp" */
628 const static struct channel_update_timestamps zero_ts = { 0, 0 };
629
630 if (timestamps_tlv) {
631 ts = decode_channel_update_timestamps(tmpctx,
632 timestamps_tlv);
633 if (!ts)
634 return towire_warningfmt(peer, NULL,
635 "reply_channel_range can't decode timestamps.");
636 if (tal_count(ts) != tal_count(scids)) {
637 return towire_warningfmt(peer, NULL,
638 "reply_channel_range %zu timestamps when %zu scids?",
639 tal_count(ts),
640 tal_count(scids));
641 }
642 } else
643 ts = NULL;
644
645 old_num = tal_count(peer->range_replies);
646 added = tal_count(scids);
647 for (i = 0; i < added; i++) {
648 tal_resize(&peer->range_replies, old_num + i + 1);
649 peer->range_replies[old_num + i].scid = scids[i];
650 if (ts)
651 peer->range_replies[old_num + i].ts = ts[i];
652 else
653 peer->range_replies[old_num + i].ts = zero_ts;
654 }
655
656 return NULL;
657}
658
659/*~ This is the reply we get when we send query_channel_range; we keep
660 * expecting them until the entire range we asked for is covered. */

Callers 1

Calls 2

towire_warningfmtFunction · 0.50

Tested by

no test coverage detected