aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2019-02-06 13:26:49 -0500
committerMarcoFalke <falke.marco@gmail.com>2019-02-06 13:26:52 -0500
commit5cdb82111cc128d68ba5268eb94787110ce1fe6e (patch)
tree78d1233db1adc8e2ae8e61d0f42974d91345951e /src
parent1a6036978e9d7fabafcd7a113a221d68bc1bd8db (diff)
parentfa2a69fcb92c7f13c07f982c46df8a64e577dab9 (diff)
downloadbitcoin-5cdb82111cc128d68ba5268eb94787110ce1fe6e.tar.xz
Merge #15321: doc: Add cs_main lock annotations for mapBlockIndex
fa2a69fcb9 doc: Add cs_main lock annotations for mapBlockIndex (practicalswift) Pull request description: Marked as "doc" because it didn't change the bitcoind on my system with default configure settings for both gcc and clang. Tree-SHA512: ba203f16c1cdc834a61c65bb5fb20bbaf7d8bff0c3a1b8ef46bc1d3669092191221e26abd7e580efab2f9bd5a992dc363251f1b68c6cd68f8204d62675868cf1
Diffstat (limited to 'src')
-rw-r--r--src/validation.cpp2
-rw-r--r--src/validation.h4
-rw-r--r--src/wallet/test/wallet_tests.cpp3
3 files changed, 6 insertions, 3 deletions
diff --git a/src/validation.cpp b/src/validation.cpp
index de9c0d96db..dbdc1afb35 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -152,7 +152,7 @@ private:
public:
CChain chainActive;
- BlockMap mapBlockIndex;
+ BlockMap mapBlockIndex GUARDED_BY(cs_main);
std::multimap<CBlockIndex*, CBlockIndex*> mapBlocksUnlinked;
CBlockIndex *pindexBestInvalid = nullptr;
diff --git a/src/validation.h b/src/validation.h
index b16d8438d7..49f73e4c9b 100644
--- a/src/validation.h
+++ b/src/validation.h
@@ -151,7 +151,7 @@ extern CBlockPolicyEstimator feeEstimator;
extern CTxMemPool mempool;
extern std::atomic_bool g_is_mempool_loaded;
typedef std::unordered_map<uint256, CBlockIndex*, BlockHasher> BlockMap;
-extern BlockMap& mapBlockIndex;
+extern BlockMap& mapBlockIndex GUARDED_BY(cs_main);
extern uint64_t nLastBlockTx;
extern uint64_t nLastBlockWeight;
extern const std::string strMessageMagic;
@@ -288,7 +288,7 @@ uint64_t CalculateCurrentUsage();
/**
* Mark one block file as pruned.
*/
-void PruneOneBlockFile(const int fileNumber);
+void PruneOneBlockFile(const int fileNumber) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
/**
* Actually unlink the specified files
diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp
index fcb34c3706..c5efd32d77 100644
--- a/src/wallet/test/wallet_tests.cpp
+++ b/src/wallet/test/wallet_tests.cpp
@@ -44,6 +44,7 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
CBlockIndex* newTip = chainActive.Tip();
+ LockAnnotation lock(::cs_main);
auto locked_chain = chain->lock();
// Verify ScanForWalletTransactions accommodates a null start block.
@@ -123,6 +124,7 @@ BOOST_FIXTURE_TEST_CASE(importmulti_rescan, TestChain100Setup)
CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
CBlockIndex* newTip = chainActive.Tip();
+ LockAnnotation lock(::cs_main);
auto locked_chain = chain->lock();
// Prune the older block file.
@@ -268,6 +270,7 @@ static int64_t AddTx(CWallet& wallet, uint32_t lockTime, int64_t mockTime, int64
SetMockTime(mockTime);
CBlockIndex* block = nullptr;
if (blockTime > 0) {
+ LockAnnotation lock(::cs_main);
auto locked_chain = wallet.chain().lock();
auto inserted = mapBlockIndex.emplace(GetRandHash(), new CBlockIndex);
assert(inserted.second);