mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-16 13:01:19 +02:00
consensus: don't call GetBlockPos in ReadBlockFromDisk without lock
Github-Pull: #22895
Rebased-From: 350e034e64
(cherry picked from commit 7febe4f3c7f482390c4aa6fc528e2ee3fb34b142)
This commit is contained in:
parent
ee109b4f28
commit
5ce127803e
1 changed files with 3 additions and 7 deletions
|
|
@ -395,17 +395,13 @@ bool ReadBlockFromDisk(CBlock& block, const FlatFilePos& pos, const Consensus::P
|
|||
|
||||
bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex, const Consensus::Params& consensusParams)
|
||||
{
|
||||
FlatFilePos blockPos;
|
||||
{
|
||||
LOCK(cs_main);
|
||||
blockPos = pindex->GetBlockPos();
|
||||
}
|
||||
const FlatFilePos block_pos{WITH_LOCK(cs_main, return pindex->GetBlockPos())};
|
||||
|
||||
if (!ReadBlockFromDisk(block, blockPos, consensusParams))
|
||||
if (!ReadBlockFromDisk(block, block_pos, consensusParams))
|
||||
return false;
|
||||
if (block.GetHash() != pindex->GetBlockHash())
|
||||
return error("ReadBlockFromDisk(CBlock&, CBlockIndex*): GetHash() doesn't match index for %s at %s",
|
||||
pindex->ToString(), pindex->GetBlockPos().ToString());
|
||||
pindex->ToString(), block_pos.ToString());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue