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

Function check_blockcount

lightningd/chaintopology.c:968–993  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

966}
967
968static void check_blockcount(struct chain_topology *topo, u32 blockcount)
969{
970 /* If bitcoind's current blockheight is below the requested
971 * height, refuse. You can always explicitly request a reindex from
972 * that block number using --rescan=. */
973 if (blockcount < topo->max_blockheight) {
974 /* UINT32_MAX == no blocks in database */
975 if (topo->max_blockheight == UINT32_MAX) {
976 /* Relative rescan, but we didn't know the blockheight */
977 /* Protect against underflow in subtraction.
978 * Possible in regtest mode. */
979 if (blockcount < topo->bitcoind->ld->config.rescan)
980 topo->max_blockheight = 0;
981 else
982 topo->max_blockheight = blockcount - topo->bitcoind->ld->config.rescan;
983 } else
984 fatal("bitcoind has gone backwards from %u to %u blocks!",
985 topo->max_blockheight, blockcount);
986 }
987
988 /* Rollback to the given blockheight, so we start track
989 * correctly again */
990 wallet_blocks_rollback(topo->ld->wallet, topo->max_blockheight);
991 /* This may have unconfirmed txs: reconfirm as we add blocks. */
992 watch_for_utxo_reconfirmation(topo, topo->ld->wallet);
993}
994
995static void retry_check_chain(struct chain_topology *topo);
996

Callers 1

check_chainFunction · 0.85

Calls 3

wallet_blocks_rollbackFunction · 0.85
fatalFunction · 0.70

Tested by

no test coverage detected