getrawblockbyheight callback for one block of a rescan: process the * block, then either fetch the next or finish. */
| 370 | /* getrawblockbyheight callback for one block of a rescan: process the |
| 371 | * block, then either fetch the next or finish. */ |
| 372 | static struct command_result *rescan_block_done(struct command *cmd, |
| 373 | const char *method UNUSED, |
| 374 | const char *buf, |
| 375 | const jsmntok_t *result, |
| 376 | struct rescan_state *rescan) |
| 377 | { |
| 378 | struct bitcoin_blkid blockhash; |
| 379 | struct bitcoin_block *block = block_from_response(buf, result, &blockhash); |
| 380 | |
| 381 | if (!block) { |
| 382 | /* Chain may have rolled back past this height; stop quietly. */ |
| 383 | plugin_log(cmd->plugin, LOG_DBG, |
| 384 | "Rescan: block %u unavailable (chain rolled back?), stopping", |
| 385 | rescan->current_block); |
| 386 | return rescan_complete(cmd); |
| 387 | } |
| 388 | |
| 389 | /* rescan->watch is forwarded so the scanner only checks that one |
| 390 | * watch (or all watches when watch == NULL). */ |
| 391 | bwatch_process_block_txs(cmd, bwatch_of(cmd->plugin), block, |
| 392 | rescan->current_block, &blockhash, rescan->watch); |
| 393 | |
| 394 | /* Advance the cursor; if we still have blocks to scan, fetch the |
| 395 | * next one and chain back into rescan_block_done. */ |
| 396 | if (++rescan->current_block <= rescan->target_block) |
| 397 | return fetch_block_rescan(cmd, rescan->current_block, |
| 398 | rescan_block_done, rescan); |
| 399 | |
| 400 | plugin_log(cmd->plugin, LOG_INFORM, "Rescan complete"); |
| 401 | return rescan_complete(cmd); |
| 402 | } |
| 403 | |
| 404 | void bwatch_start_rescan(struct command *cmd, |
| 405 | const struct watch *w, |
nothing calls this directly
no test coverage detected