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

Function append_range_reply

gossipd/queries.c:142–179  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 2

towire_warningfmtFunction · 0.50

Tested by

no test coverage detected