doc: Add cs_main lock annotations for mapBlockIndex

pull/643/head
practicalswift 6 years ago committed by MarcoFalke
parent 3e38d40873
commit fa2a69fcb9
No known key found for this signature in database
GPG Key ID: CE2B75697E69A548

@ -152,7 +152,7 @@ private:
public: public:
CChain chainActive; CChain chainActive;
BlockMap mapBlockIndex; BlockMap mapBlockIndex GUARDED_BY(cs_main);
std::multimap<CBlockIndex*, CBlockIndex*> mapBlocksUnlinked; std::multimap<CBlockIndex*, CBlockIndex*> mapBlocksUnlinked;
CBlockIndex *pindexBestInvalid = nullptr; CBlockIndex *pindexBestInvalid = nullptr;

@ -151,7 +151,7 @@ extern CBlockPolicyEstimator feeEstimator;
extern CTxMemPool mempool; extern CTxMemPool mempool;
extern std::atomic_bool g_is_mempool_loaded; extern std::atomic_bool g_is_mempool_loaded;
typedef std::unordered_map<uint256, CBlockIndex*, BlockHasher> BlockMap; 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 nLastBlockTx;
extern uint64_t nLastBlockWeight; extern uint64_t nLastBlockWeight;
extern const std::string strMessageMagic; extern const std::string strMessageMagic;
@ -288,7 +288,7 @@ uint64_t CalculateCurrentUsage();
/** /**
* Mark one block file as pruned. * 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 * Actually unlink the specified files

@ -44,6 +44,7 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey())); CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
CBlockIndex* newTip = chainActive.Tip(); CBlockIndex* newTip = chainActive.Tip();
LockAnnotation lock(::cs_main);
auto locked_chain = chain->lock(); auto locked_chain = chain->lock();
// Verify ScanForWalletTransactions accommodates a null start block. // Verify ScanForWalletTransactions accommodates a null start block.
@ -123,6 +124,7 @@ BOOST_FIXTURE_TEST_CASE(importmulti_rescan, TestChain100Setup)
CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey())); CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
CBlockIndex* newTip = chainActive.Tip(); CBlockIndex* newTip = chainActive.Tip();
LockAnnotation lock(::cs_main);
auto locked_chain = chain->lock(); auto locked_chain = chain->lock();
// Prune the older block file. // Prune the older block file.
@ -268,6 +270,7 @@ static int64_t AddTx(CWallet& wallet, uint32_t lockTime, int64_t mockTime, int64
SetMockTime(mockTime); SetMockTime(mockTime);
CBlockIndex* block = nullptr; CBlockIndex* block = nullptr;
if (blockTime > 0) { if (blockTime > 0) {
LockAnnotation lock(::cs_main);
auto locked_chain = wallet.chain().lock(); auto locked_chain = wallet.chain().lock();
auto inserted = mapBlockIndex.emplace(GetRandHash(), new CBlockIndex); auto inserted = mapBlockIndex.emplace(GetRandHash(), new CBlockIndex);
assert(inserted.second); assert(inserted.second);

Loading…
Cancel
Save