mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 10:38:42 +01:00
Assert cs_main is held when accessing mapBlockIndex
This commit is contained in:
parent
765a3ebb02
commit
02de6a6bcd
@ -260,6 +260,8 @@ namespace {
|
||||
|
||||
CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& locator)
|
||||
{
|
||||
AssertLockHeld(cs_main);
|
||||
|
||||
// Find the first block the caller has in the main chain
|
||||
for (const uint256& hash : locator.vHave) {
|
||||
BlockMap::iterator mi = mapBlockIndex.find(hash);
|
||||
@ -2774,6 +2776,8 @@ bool ResetBlockFailureFlags(CBlockIndex *pindex) {
|
||||
|
||||
CBlockIndex* CChainState::AddToBlockIndex(const CBlockHeader& block)
|
||||
{
|
||||
AssertLockHeld(cs_main);
|
||||
|
||||
// Check for duplicate
|
||||
uint256 hash = block.GetHash();
|
||||
BlockMap::iterator it = mapBlockIndex.find(hash);
|
||||
@ -3654,6 +3658,8 @@ fs::path GetBlockPosFilename(const CDiskBlockPos &pos, const char *prefix)
|
||||
|
||||
CBlockIndex * CChainState::InsertBlockIndex(const uint256& hash)
|
||||
{
|
||||
AssertLockHeld(cs_main);
|
||||
|
||||
if (hash.IsNull())
|
||||
return nullptr;
|
||||
|
||||
@ -3781,6 +3787,8 @@ bool static LoadBlockIndexDB(const CChainParams& chainparams)
|
||||
|
||||
bool LoadChainTip(const CChainParams& chainparams)
|
||||
{
|
||||
AssertLockHeld(cs_main);
|
||||
|
||||
if (chainActive.Tip() && chainActive.Tip()->GetBlockHash() == pcoinsTip->GetBestBlock()) return true;
|
||||
|
||||
if (pcoinsTip->GetBestBlock().IsNull() && mapBlockIndex.size() == 1) {
|
||||
|
Loading…
Reference in New Issue
Block a user