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

Function listpeers_done

plugins/topology.c:348–401  ·  view source on GitHub ↗

We want to combine local knowledge to we know which are actually inactive! */

Source from the content-addressed store, hash-verified

346
347/* We want to combine local knowledge to we know which are actually inactive! */
348static struct command_result *listpeers_done(struct command *cmd,
349 const char *buf,
350 const jsmntok_t *result,
351 struct listchannels_opts *opts)
352{
353 struct node_map *connected;
354 struct gossmap_chan *c;
355 struct json_stream *js;
356 struct gossmap *gossmap = get_gossmap();
357
358 connected = local_connected(opts, buf, result);
359
360 js = jsonrpc_stream_success(cmd);
361 json_array_start(js, "channels");
362 if (opts->scid) {
363 c = gossmap_find_chan(gossmap, opts->scid);
364 if (c)
365 json_add_halfchan(js, gossmap, connected, c, 3);
366 } else if (opts->source) {
367 struct gossmap_node *src;
368
369 src = gossmap_find_node(gossmap, opts->source);
370 if (src) {
371 for (size_t i = 0; i < src->num_chans; i++) {
372 int dir;
373 c = gossmap_nth_chan(gossmap, src, i, &dir);
374 json_add_halfchan(js, gossmap, connected,
375 c, 1 << dir);
376 }
377 }
378 } else if (opts->destination) {
379 struct gossmap_node *dst;
380
381 dst = gossmap_find_node(gossmap, opts->destination);
382 if (dst) {
383 for (size_t i = 0; i < dst->num_chans; i++) {
384 int dir;
385 c = gossmap_nth_chan(gossmap, dst, i, &dir);
386 json_add_halfchan(js, gossmap, connected,
387 c, 1 << !dir);
388 }
389 }
390 } else {
391 for (c = gossmap_first_chan(gossmap);
392 c;
393 c = gossmap_next_chan(gossmap, c)) {
394 json_add_halfchan(js, gossmap, connected, c, 3);
395 }
396 }
397
398 json_array_end(js);
399
400 return command_finished(cmd, js);
401}
402
403static struct command_result *json_listchannels(struct command *cmd,
404 const char *buffer,

Callers

nothing calls this directly

Calls 12

local_connectedFunction · 0.85
gossmap_find_chanFunction · 0.85
json_add_halfchanFunction · 0.85
gossmap_find_nodeFunction · 0.85
gossmap_nth_chanFunction · 0.85
gossmap_first_chanFunction · 0.85
gossmap_next_chanFunction · 0.85
get_gossmapFunction · 0.70
jsonrpc_stream_successFunction · 0.70
command_finishedFunction · 0.70
json_array_startFunction · 0.50
json_array_endFunction · 0.50

Tested by

no test coverage detected