Reduce cs_main lock in ReadBlockFromDisk, only read GetBlockPos under the lock

This commit is contained in:
Jonas Schnelli
2017-12-13 11:06:51 -10:00
parent bc356b4268
commit ccd8ef65f9
2 changed files with 8 additions and 7 deletions

View File

@@ -1689,13 +1689,8 @@ CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, CBlock
LogPrintf("Still rescanning. At block %d. Progress=%f\n", pindex->nHeight, GuessVerificationProgress(chainParams.TxData(), pindex));
}
bool readRet = false;
CBlock block;
{
LOCK(cs_main);
readRet = ReadBlockFromDisk(block, pindex, Params().GetConsensus());
}
if (readRet) {
if (ReadBlockFromDisk(block, pindex, Params().GetConsensus())) {
LOCK2(cs_main, cs_wallet);
if (pindex && !chainActive.Contains(pindex)) {
// Abort scan if current block is no longer active, to prevent