| 805 | } |
| 806 | |
| 807 | void 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 | |
| 844 | void remove_layer(struct layer *l) |
| 845 | { |
no test coverage detected