mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
Reduce cs_main lock in ReadBlockFromDisk, only read GetBlockPos under the lock
This commit is contained in:
parent
bc356b4268
commit
ccd8ef65f9
@ -1121,7 +1121,13 @@ bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos, const Consensus:
|
||||
|
||||
bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex, const Consensus::Params& consensusParams)
|
||||
{
|
||||
if (!ReadBlockFromDisk(block, pindex->GetBlockPos(), consensusParams))
|
||||
CDiskBlockPos blockPos;
|
||||
{
|
||||
LOCK(cs_main);
|
||||
blockPos = pindex->GetBlockPos();
|
||||
}
|
||||
|
||||
if (!ReadBlockFromDisk(block, blockPos, consensusParams))
|
||||
return false;
|
||||
if (block.GetHash() != pindex->GetBlockHash())
|
||||
return error("ReadBlockFromDisk(CBlock&, CBlockIndex*): GetHash() doesn't match index for %s at %s",
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user