| 402 | } |
| 403 | |
| 404 | void bwatch_start_rescan(struct command *cmd, |
| 405 | const struct watch *w, |
| 406 | u32 start_block, |
| 407 | u32 target_block) |
| 408 | { |
| 409 | struct rescan_state *rescan; |
| 410 | |
| 411 | if (w) { |
| 412 | plugin_log(cmd->plugin, LOG_INFORM, |
| 413 | "Starting rescan for %s watch: blocks %u-%u", |
| 414 | bwatch_get_watch_type_name(w->type), |
| 415 | start_block, target_block); |
| 416 | } else { |
| 417 | plugin_log(cmd->plugin, LOG_INFORM, |
| 418 | "Starting rescan for all watches: blocks %u-%u", |
| 419 | start_block, target_block); |
| 420 | } |
| 421 | |
| 422 | /* Owned by `cmd` so it lives across the async chain and gets |
| 423 | * freed automatically when the command completes. */ |
| 424 | rescan = tal(cmd, struct rescan_state); |
| 425 | rescan->watch = w; |
| 426 | rescan->current_block = start_block; |
| 427 | rescan->target_block = target_block; |
| 428 | |
| 429 | /* Fire the first getrawblockbyheight; each response runs |
| 430 | * rescan_block_done, which fetches the next block until we |
| 431 | * pass target_block. */ |
| 432 | fetch_block_rescan(cmd, rescan->current_block, |
| 433 | rescan_block_done, rescan); |
| 434 | } |
| 435 | |
| 436 | static const char *init(struct command *cmd, |
| 437 | const char *buf UNUSED, |
no test coverage detected