Called by lightningd at each new block. */
| 3663 | } |
| 3664 | /* Called by lightningd at each new block. */ |
| 3665 | void waitblockheight_notify_new_block(struct lightningd *ld) |
| 3666 | { |
| 3667 | u32 block_height = get_block_height(ld->topology); |
| 3668 | struct waitblockheight_waiter *w, *n; |
| 3669 | char *to_delete = tal(NULL, char); |
| 3670 | |
| 3671 | /* Use safe since we could resolve commands and thus |
| 3672 | * trigger removal of list elements. |
| 3673 | */ |
| 3674 | list_for_each_safe(&ld->waitblockheight_commands, w, n, list) { |
| 3675 | /* Skip commands that have not been reached yet. */ |
| 3676 | if (w->block_height > block_height) |
| 3677 | continue; |
| 3678 | |
| 3679 | list_del(&w->list); |
| 3680 | w->removed = true; |
| 3681 | tal_steal(to_delete, w); |
| 3682 | was_pending(waitblockheight_complete(w->cmd, block_height)); |
| 3683 | } |
| 3684 | tal_free(to_delete); |
| 3685 | } |
| 3686 | static struct command_result *json_waitblockheight(struct command *cmd, |
| 3687 | const char *buffer, |
| 3688 | const jsmntok_t *obj, |
no test coverage detected