Skip to content

Commit 151c733

Browse files
committed
wallet: use SetBestBlock when saving progress during rescan
Instead of writing the best block record directly during a rescan, use SetBestBlock. This is safe because progress is only saved in a rescan when doing a rescan on loading. cs_wallet is held the entire time so new blocks or reorgs will not cause the best block record to be changed unexpectedly.
1 parent 1f209f9 commit 151c733

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/wallet/wallet.cpp

+2-7
Original file line numberDiff line numberDiff line change
@@ -1985,13 +1985,8 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
19851985
result.last_scanned_height = block_height;
19861986

19871987
if (save_progress && next_interval) {
1988-
CBlockLocator loc = m_chain->getActiveChainLocator(block_hash);
1989-
1990-
if (!loc.IsNull()) {
1991-
WalletLogPrintf("Saving scan progress %d.\n", block_height);
1992-
WalletBatch batch(GetDatabase());
1993-
batch.WriteBestBlock(BestBlock{loc, block_hash, block_height});
1994-
}
1988+
WalletLogPrintf("Saving scan progress %d.\n", block_height);
1989+
SetBestBlock(block_height, block_hash);
19951990
}
19961991
} else {
19971992
// could not scan block, keep scanning but record this block as the most recent failure

0 commit comments

Comments
 (0)