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

Function handle_reply_channel_range

gossipd/queries.c:183–359  ·  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

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. */
183const 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 *...

Callers 1

handle_recv_gossipFunction · 0.85

Calls 6

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

Tested by

no test coverage detected