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

Function append_range_reply

gossipd/queries.c:144–181  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

142
143/* Append these scids (and optional timestamps) to our pending replies */
144static u8 *append_range_reply(struct peer *peer,
145 const struct short_channel_id *scids,
146 const struct tlv_reply_channel_range_tlvs_timestamps_tlv
147 *timestamps_tlv)
148{
149 size_t old_num, added;
150 const struct channel_update_timestamps *ts;
151 /* Zero means "no timestamp" */
152 const static struct channel_update_timestamps zero_ts = { 0, 0 };
153
154 if (timestamps_tlv) {
155 ts = decode_channel_update_timestamps(tmpctx,
156 timestamps_tlv);
157 if (!ts)
158 return towire_warningfmt(peer, NULL,
159 "reply_channel_range can't decode timestamps.");
160 if (tal_count(ts) != tal_count(scids)) {
161 return towire_warningfmt(peer, NULL,
162 "reply_channel_range %zu timestamps when %zu scids?",
163 tal_count(ts),
164 tal_count(scids));
165 }
166 } else
167 ts = NULL;
168
169 old_num = tal_count(peer->range_replies);
170 added = tal_count(scids);
171 tal_resize(&peer->range_replies, old_num + added);
172 for (size_t i = 0; i < added; i++) {
173 peer->range_replies[old_num + i].scid = scids[i];
174 if (ts)
175 peer->range_replies[old_num + i].ts = ts[i];
176 else
177 peer->range_replies[old_num + i].ts = zero_ts;
178 }
179
180 return NULL;
181}
182
183/*~ This is the reply we get when we send query_channel_range; we keep
184 * 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