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

Function handle_reply_channel_range

gossipd/queries.c:661–837  ·  view source on GitHub ↗

~ 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. */

Source from the content-addressed store, hash-verified

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. */
661const u8 *handle_reply_channel_range(struct peer *peer, const u8 *msg)
662{
663 struct bitcoin_blkid chain;
664 u8 sync_complete;
665 u32 first_blocknum, number_of_blocks, start, end;
666 u8 *encoded;
667 struct short_channel_id *scids;
668 const struct range_query_reply *replies;
669 const u8 *err;
670 void (*cb)(struct peer *peer,
671 u32 first_blocknum, u32 number_of_blocks,
672 const struct range_query_reply *replies);
673 struct tlv_reply_channel_range_tlvs *tlvs;
674
675 if (!fromwire_reply_channel_range(tmpctx, msg, &chain, &first_blocknum,
676 &number_of_blocks, &sync_complete,
677 &encoded, &tlvs)) {
678 return towire_warningfmt(peer, NULL,
679 "Bad reply_channel_range w/tlvs %s",
680 tal_hex(tmpctx, msg));
681 }
682
683 if (!bitcoin_blkid_eq(&chainparams->genesis_blockhash, &chain)) {
684 return towire_warningfmt(peer, NULL,
685 "reply_channel_range for bad chain: %s",
686 tal_hex(tmpctx, msg));
687 }
688
689 if (!peer->range_replies) {
690 return towire_warningfmt(peer, NULL,
691 "reply_channel_range without query: %s",
692 tal_hex(tmpctx, msg));
693 }
694
695 /* Beware overflow! */
696 if (first_blocknum + number_of_blocks < first_blocknum) {
697 return towire_warningfmt(peer, NULL,
698 "reply_channel_range invalid %u+%u",
699 first_blocknum, number_of_blocks);
700 }
701
702 scids = decode_short_ids(tmpctx, encoded);
703 if (!scids) {
704 return towire_warningfmt(peer, NULL,
705 "Bad reply_channel_range encoding %s",
706 tal_hex(tmpctx, encoded));
707 }
708
709 status_peer_debug(&peer->id,
710 "reply_channel_range %u+%u (of %u+%u) %zu scids",
711 first_blocknum, number_of_blocks,
712 peer->range_first_blocknum,
713 peer->range_end_blocknum - peer->range_first_blocknum,
714 tal_count(scids));
715
716 /* BOLT #7:
717 * The receiver of `query_channel_range`:
718 *...

Callers 1

handle_recv_gossipFunction · 0.85

Calls 6

tal_hexFunction · 0.85
tal_bytelenFunction · 0.85
append_range_replyFunction · 0.85
towire_warningfmtFunction · 0.50
decode_short_idsFunction · 0.50

Tested by

no test coverage detected