Called by lightningd at each new block. */
| 3455 | } |
| 3456 | /* Called by lightningd at each new block. */ |
| 3457 | void waitblockheight_notify_new_block(struct lightningd *ld) |
| 3458 | { |
| 3459 | u32 block_height = get_block_height(ld->topology); |
| 3460 | struct waitblockheight_waiter *w, *n; |
| 3461 | char *to_delete = tal(NULL, char); |
| 3462 | |
| 3463 | /* Use safe since we could resolve commands and thus |
| 3464 | * trigger removal of list elements. |
| 3465 | */ |
| 3466 | list_for_each_safe(&ld->waitblockheight_commands, w, n, list) { |
| 3467 | /* Skip commands that have not been reached yet. */ |
| 3468 | if (w->block_height > block_height) |
| 3469 | continue; |
| 3470 | |
| 3471 | list_del(&w->list); |
| 3472 | w->removed = true; |
| 3473 | tal_steal(to_delete, w); |
| 3474 | was_pending(waitblockheight_complete(w->cmd, block_height)); |
| 3475 | } |
| 3476 | tal_free(to_delete); |
| 3477 | } |
| 3478 | static struct command_result *json_waitblockheight(struct command *cmd, |
| 3479 | const char *buffer, |
| 3480 | const jsmntok_t *obj, |
no test coverage detected