Called by lightningd at each new block. */
| 3733 | } |
| 3734 | /* Called by lightningd at each new block. */ |
| 3735 | void waitblockheight_notify_new_block(struct lightningd *ld) |
| 3736 | { |
| 3737 | u32 block_height = get_block_height(ld->topology); |
| 3738 | struct waitblockheight_waiter *w, *n; |
| 3739 | char *to_delete = tal(NULL, char); |
| 3740 | |
| 3741 | /* Use safe since we could resolve commands and thus |
| 3742 | * trigger removal of list elements. |
| 3743 | */ |
| 3744 | list_for_each_safe(&ld->waitblockheight_commands, w, n, list) { |
| 3745 | /* Skip commands that have not been reached yet. */ |
| 3746 | if (w->block_height > block_height) |
| 3747 | continue; |
| 3748 | |
| 3749 | list_del(&w->list); |
| 3750 | w->removed = true; |
| 3751 | tal_steal(to_delete, w); |
| 3752 | was_pending(waitblockheight_complete(w->cmd, block_height)); |
| 3753 | } |
| 3754 | tal_free(to_delete); |
| 3755 | } |
| 3756 | static struct command_result *json_waitblockheight(struct command *cmd, |
| 3757 | const char *buffer, |
| 3758 | const jsmntok_t *obj, |
no test coverage detected