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

Function load_layers

plugins/askrene/layer.c:807–842  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

805}
806
807void load_layers(struct askrene *askrene, struct command *init_cmd)
808{
809 struct json_out *params = json_out_new(init_cmd);
810 const jsmntok_t *result;
811 const char *buf;
812 const jsmntok_t *datastore, *t, *key, *data;
813 size_t i;
814
815
816 json_out_start(params, NULL, '{');
817 json_out_start(params, "key", '[');
818 json_out_addstr(params, NULL, "askrene");
819 json_out_addstr(params, NULL, "layers");
820 json_out_end(params, ']');
821 json_out_end(params, '}');
822
823 result = jsonrpc_request_sync(tmpctx, init_cmd,
824 "listdatastore",
825 params, &buf);
826
827 datastore = json_get_member(buf, result, "datastore");
828 json_for_each_arr(i, t, datastore) {
829 const char *layername;
830
831 /* Key is an array, first two elements are askrene, layers */
832 key = json_get_member(buf, t, "key") + 3;
833 data = json_get_member(buf, t, "hex");
834 /* In case someone creates a subdir? */
835 if (!data)
836 continue;
837 layername = json_strdup(NULL, buf, key);
838 populate_layer(askrene,
839 take(layername),
840 json_tok_bin_from_hex(tmpctx, buf, data));
841 }
842}
843
844void remove_layer(struct layer *l)
845{

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