Called by lightningd at each new block. */
| 2377 | } |
| 2378 | /* Called by lightningd at each new block. */ |
| 2379 | void waitblockheight_notify_new_block(struct lightningd *ld, |
| 2380 | u32 block_height) |
| 2381 | { |
| 2382 | struct waitblockheight_waiter *w, *n; |
| 2383 | char *to_delete = tal(NULL, char); |
| 2384 | |
| 2385 | /* Use safe since we could resolve commands and thus |
| 2386 | * trigger removal of list elements. |
| 2387 | */ |
| 2388 | list_for_each_safe(&ld->waitblockheight_commands, w, n, list) { |
| 2389 | /* Skip commands that have not been reached yet. */ |
| 2390 | if (w->block_height > block_height) |
| 2391 | continue; |
| 2392 | |
| 2393 | list_del(&w->list); |
| 2394 | w->removed = true; |
| 2395 | tal_steal(to_delete, w); |
| 2396 | was_pending(waitblockheight_complete(w->cmd, |
| 2397 | block_height)); |
| 2398 | } |
| 2399 | tal_free(to_delete); |
| 2400 | } |
| 2401 | static struct command_result *json_waitblockheight(struct command *cmd, |
| 2402 | const char *buffer, |
| 2403 | const jsmntok_t *obj, |
no test coverage detected