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

Function load_layers

plugins/askrene/layer.c:820–855  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

818}
819
820void load_layers(struct askrene *askrene, struct command *init_cmd)
821{
822 struct json_out *params = json_out_new(init_cmd);
823 const jsmntok_t *result;
824 const char *buf;
825 const jsmntok_t *datastore, *t, *key, *data;
826 size_t i;
827
828
829 json_out_start(params, NULL, '{');
830 json_out_start(params, "key", '[');
831 json_out_addstr(params, NULL, "askrene");
832 json_out_addstr(params, NULL, "layers");
833 json_out_end(params, ']');
834 json_out_end(params, '}');
835
836 result = jsonrpc_request_sync(tmpctx, init_cmd,
837 "listdatastore",
838 params, &buf);
839
840 datastore = json_get_member(buf, result, "datastore");
841 json_for_each_arr(i, t, datastore) {
842 const char *layername;
843
844 /* Key is an array, first two elements are askrene, layers */
845 key = json_get_member(buf, t, "key") + 3;
846 data = json_get_member(buf, t, "hex");
847 /* In case someone creates a subdir? */
848 if (!data)
849 continue;
850 layername = json_strdup(NULL, buf, key);
851 populate_layer(askrene,
852 take(layername),
853 json_tok_bin_from_hex(tmpctx, buf, data));
854 }
855}
856
857void remove_layer(struct layer *l)
858{

Callers 1

initFunction · 0.85

Calls 9

json_out_newFunction · 0.85
json_out_startFunction · 0.85
json_out_addstrFunction · 0.85
json_out_endFunction · 0.85
json_get_memberFunction · 0.85
populate_layerFunction · 0.85
jsonrpc_request_syncFunction · 0.50
json_strdupFunction · 0.50
json_tok_bin_from_hexFunction · 0.50

Tested by

no test coverage detected