| 212 | |
| 213 | #define LISTCHANNELMOVES_LIMIT 10000 |
| 214 | static struct command_result *listchannelmoves_done(struct command *cmd, |
| 215 | const char *method, |
| 216 | const char *buf, |
| 217 | const jsmntok_t *result, |
| 218 | struct refresh_info *rinfo) |
| 219 | { |
| 220 | const jsmntok_t *moves, *t; |
| 221 | size_t i; |
| 222 | struct bkpr *bkpr = bkpr_of(cmd->plugin); |
| 223 | be64 be_index; |
| 224 | |
| 225 | moves = json_get_member(buf, result, "channelmoves"); |
| 226 | json_for_each_arr(i, t, moves) |
| 227 | parse_and_log_channel_move(cmd, buf, t, rinfo); |
| 228 | |
| 229 | be_index = cpu_to_be64(bkpr->channelmoves_index); |
| 230 | jsonrpc_set_datastore_binary(cmd, |
| 231 | mkdatastorekey(tmpctx, "bookkeeper", "channelmoves_index"), |
| 232 | &be_index, sizeof(be_index), |
| 233 | "create-or-replace", |
| 234 | datastore_done, NULL, use_rinfo(rinfo)); |
| 235 | |
| 236 | /* If there might be more, try asking for more */ |
| 237 | if (moves->size == LISTCHANNELMOVES_LIMIT) |
| 238 | limited_listchannelmoves(cmd, rinfo); |
| 239 | |
| 240 | return rinfo_one_done(cmd, rinfo); |
| 241 | } |
| 242 | |
| 243 | /* We do 1000 at a time to avoid overwhelming lightningd */ |
| 244 | static struct command_result *limited_listchannelmoves(struct command *cmd, |
nothing calls this directly
no test coverage detected