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

Function json_add_peer

lightningd/peer_control.c:2859–2893  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2857}
2858
2859static void json_add_peer(struct lightningd *ld,
2860 struct json_stream *response,
2861 struct peer *p,
2862 const enum log_level *ll)
2863{
2864 struct channel *channel;
2865 u32 num_channels;
2866
2867 json_object_start(response, NULL);
2868 json_add_node_id(response, "id", &p->id);
2869
2870 json_add_bool(response, "connected", p->connected == PEER_CONNECTED);
2871 num_channels = 0;
2872 list_for_each(&p->channels, channel, list)
2873 num_channels++;
2874 json_add_num(response, "num_channels", num_channels);
2875
2876 if (p->connected == PEER_CONNECTED) {
2877 json_array_start(response, "netaddr");
2878 json_add_string(response, NULL,
2879 fmt_wireaddr_internal(tmpctx, &p->addr));
2880 json_array_end(response);
2881 /* If peer reports our IP remote_addr, add that here */
2882 if (p->remote_addr)
2883 json_add_string(response, "remote_addr",
2884 fmt_wireaddr(tmpctx, p->remote_addr));
2885 }
2886
2887 /* Note: If !PEER_CONNECTED, peer may use different features on reconnect */
2888 json_add_hex_talarr(response, "features", p->their_features);
2889
2890 if (ll)
2891 json_add_log(response, ld->log_book, &p->id, *ll);
2892 json_object_end(response);
2893}
2894
2895static struct command_result *json_listpeers(struct command *cmd,
2896 const char *buffer,

Callers 1

json_listpeersFunction · 0.85

Calls 12

json_object_startFunction · 0.85
json_add_node_idFunction · 0.85
json_add_boolFunction · 0.85
json_add_numFunction · 0.85
json_array_startFunction · 0.85
fmt_wireaddr_internalFunction · 0.85
json_array_endFunction · 0.85
fmt_wireaddrFunction · 0.85
json_add_hex_talarrFunction · 0.85
json_object_endFunction · 0.85
json_add_logFunction · 0.70
json_add_stringFunction · 0.50

Tested by

no test coverage detected