MCPcopy Create free account
hub / github.com/ElementsProject/lightning / rescan_block_done

Function rescan_block_done

plugins/bwatch/bwatch.c:372–402  ·  view source on GitHub ↗

getrawblockbyheight callback for one block of a rescan: process the * block, then either fetch the next or finish. */

Source from the content-addressed store, hash-verified

370/* getrawblockbyheight callback for one block of a rescan: process the
371 * block, then either fetch the next or finish. */
372static 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
404void bwatch_start_rescan(struct command *cmd,
405 const struct watch *w,

Callers

nothing calls this directly

Calls 6

block_from_responseFunction · 0.85
rescan_completeFunction · 0.85
bwatch_process_block_txsFunction · 0.85
bwatch_ofFunction · 0.85
fetch_block_rescanFunction · 0.85
plugin_logFunction · 0.50

Tested by

no test coverage detected