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

Function json_waitblockheight

lightningd/peer_control.c:3756–3789  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3754 tal_free(to_delete);
3755}
3756static struct command_result *json_waitblockheight(struct command *cmd,
3757 const char *buffer,
3758 const jsmntok_t *obj,
3759 const jsmntok_t *params)
3760{
3761 unsigned int *target_block_height;
3762 u32 block_height;
3763 unsigned int *timeout;
3764 struct waitblockheight_waiter *w;
3765
3766 if (!param(cmd, buffer, params,
3767 p_req("blockheight", param_number, &target_block_height),
3768 p_opt_def("timeout", param_number, &timeout, 60),
3769 NULL))
3770 return command_param_failed();
3771
3772 /* Check if already reached anyway. */
3773 block_height = get_block_height(cmd->ld->topology);
3774 if (*target_block_height <= block_height)
3775 return waitblockheight_complete(cmd, block_height);
3776
3777 /* Create a new waitblockheight command. */
3778 w = tal(cmd, struct waitblockheight_waiter);
3779 tal_add_destructor(w, &destroy_waitblockheight_waiter);
3780 list_add(&cmd->ld->waitblockheight_commands, &w->list);
3781 w->cmd = cmd;
3782 w->block_height = *target_block_height;
3783 w->removed = false;
3784 /* Install the timeout. */
3785 (void) new_reltimer(cmd->ld->timers, w, time_from_sec(*timeout),
3786 &timeout_waitblockheight_waiter, w);
3787
3788 return command_still_pending(cmd);
3789}
3790
3791static const struct json_command waitblockheight_command = {
3792 "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