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

Function json_waitblockheight

lightningd/peer_control.c:3478–3511  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3476 tal_free(to_delete);
3477}
3478static struct command_result *json_waitblockheight(struct command *cmd,
3479 const char *buffer,
3480 const jsmntok_t *obj,
3481 const jsmntok_t *params)
3482{
3483 unsigned int *target_block_height;
3484 u32 block_height;
3485 unsigned int *timeout;
3486 struct waitblockheight_waiter *w;
3487
3488 if (!param(cmd, buffer, params,
3489 p_req("blockheight", param_number, &target_block_height),
3490 p_opt_def("timeout", param_number, &timeout, 60),
3491 NULL))
3492 return command_param_failed();
3493
3494 /* Check if already reached anyway. */
3495 block_height = get_block_height(cmd->ld->topology);
3496 if (*target_block_height <= block_height)
3497 return waitblockheight_complete(cmd, block_height);
3498
3499 /* Create a new waitblockheight command. */
3500 w = tal(cmd, struct waitblockheight_waiter);
3501 tal_add_destructor(w, &destroy_waitblockheight_waiter);
3502 list_add(&cmd->ld->waitblockheight_commands, &w->list);
3503 w->cmd = cmd;
3504 w->block_height = *target_block_height;
3505 w->removed = false;
3506 /* Install the timeout. */
3507 (void) new_reltimer(cmd->ld->timers, w, time_from_sec(*timeout),
3508 &timeout_waitblockheight_waiter, w);
3509
3510 return command_still_pending(cmd);
3511}
3512
3513static const struct json_command waitblockheight_command = {
3514 "waitblockheight",

Callers

nothing calls this directly

Calls 6

waitblockheight_completeFunction · 0.85
time_from_secFunction · 0.85
command_param_failedFunction · 0.70
get_block_heightFunction · 0.70
command_still_pendingFunction · 0.70
paramFunction · 0.50

Tested by

no test coverage detected