| 284 | } |
| 285 | |
| 286 | static struct command_result *refresh_moves_(struct command *cmd, |
| 287 | struct command_result *(*cb)( |
| 288 | struct command *, |
| 289 | void *), |
| 290 | void *arg) |
| 291 | { |
| 292 | struct out_req *req; |
| 293 | struct bkpr *bkpr = bkpr_of(cmd->plugin); |
| 294 | struct refresh_cb refresh_cb; |
| 295 | |
| 296 | refresh_cb.cmd = cmd; |
| 297 | refresh_cb.cb = cb; |
| 298 | refresh_cb.arg = arg; |
| 299 | |
| 300 | /* If rinfo already running, just jump on that. |
| 301 | * |
| 302 | * NOTE: We assume cmd will not exit before refresh, which is |
| 303 | * currently true, otherwise we'd need a destructor to remove it. */ |
| 304 | if (bkpr->rinfo) { |
| 305 | tal_arr_expand(&bkpr->rinfo->callbacks, refresh_cb); |
| 306 | return command_still_pending(cmd); |
| 307 | } |
| 308 | |
| 309 | bkpr->rinfo = tal(bkpr, struct refresh_info); |
| 310 | bkpr->rinfo->calls_remaining = 0; |
| 311 | bkpr->rinfo->callbacks = tal_dup_arr(bkpr->rinfo, struct refresh_cb, &refresh_cb, 1, 0); |
| 312 | |
| 313 | req = jsonrpc_request_start(cmd, "listchainmoves", |
| 314 | listchainmoves_done, |
| 315 | plugin_broken_cb, |
| 316 | use_rinfo(bkpr->rinfo)); |
| 317 | json_add_string(req->js, "index", "created"); |
| 318 | json_add_u64(req->js, "start", bkpr->chainmoves_index + 1); |
| 319 | return send_outreq(req); |
| 320 | } |
| 321 | |
| 322 | #define refresh_moves(cmd, cb, arg) \ |
| 323 | refresh_moves_((cmd), \ |
nothing calls this directly
no test coverage detected