aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoão Barbosa <joao.paulo.barbosa@gmail.com>2018-01-11 23:32:32 +0000
committerJoão Barbosa <joao.paulo.barbosa@gmail.com>2018-03-06 19:21:15 +0000
commit02de6a6bcda8bef4c35eb6c5135529fdf51f0f88 (patch)
tree8a754d97456d3689349c4f4a74b13cdfb583f7c3 /src
parent765a3ebb026826f3f4765f5bbc9ed77ee23d67ba (diff)
downloadbitcoin-02de6a6bcda8bef4c35eb6c5135529fdf51f0f88.tar.xz
Assert cs_main is held when accessing mapBlockIndex
Diffstat (limited to 'src')
-rw-r--r--src/validation.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/validation.cpp b/src/validation.cpp
index a77362f5d6..18412d9e94 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -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) {