@@ -157,16 +157,16 @@ class CChainState {
157157 std::multimap<CBlockIndex*, CBlockIndex*> mapBlocksUnlinked;
158158 CBlockIndex *pindexBestInvalid = nullptr ;
159159
160- bool LoadBlockIndex (const Consensus::Params& consensus_params, CBlockTreeDB& blocktree);
160+ bool LoadBlockIndex (const Consensus::Params& consensus_params, CBlockTreeDB& blocktree) EXCLUSIVE_LOCKS_REQUIRED(cs_main) ;
161161
162162 bool ActivateBestChain (CValidationState &state, const CChainParams& chainparams, std::shared_ptr<const CBlock> pblock);
163163
164164 /* *
165165 * If a block header hasn't already been seen, call CheckBlockHeader on it, ensure
166166 * that it doesn't descend from an invalid block, and then add it to mapBlockIndex.
167167 */
168- bool AcceptBlockHeader (const CBlockHeader& block, CValidationState& state, const CChainParams& chainparams, CBlockIndex** ppindex);
169- bool AcceptBlock (const std::shared_ptr<const CBlock>& pblock, CValidationState& state, const CChainParams& chainparams, CBlockIndex** ppindex, bool fRequested , const CDiskBlockPos* dbp, bool * fNewBlock );
168+ bool AcceptBlockHeader (const CBlockHeader& block, CValidationState& state, const CChainParams& chainparams, CBlockIndex** ppindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main) ;
169+ bool AcceptBlock (const std::shared_ptr<const CBlock>& pblock, CValidationState& state, const CChainParams& chainparams, CBlockIndex** ppindex, bool fRequested , const CDiskBlockPos* dbp, bool * fNewBlock ) EXCLUSIVE_LOCKS_REQUIRED(cs_main) ;
170170
171171 // Block (dis)connection on a given view:
172172 DisconnectResult DisconnectBlock (const CBlock& block, const CBlockIndex* pindex, CCoinsViewCache& view);
@@ -177,9 +177,9 @@ class CChainState {
177177 bool DisconnectTip (CValidationState& state, const CChainParams& chainparams, DisconnectedBlockTransactions *disconnectpool);
178178
179179 // Manual block validity manipulation:
180- bool PreciousBlock (CValidationState& state, const CChainParams& params, CBlockIndex * pindex);
181- bool InvalidateBlock (CValidationState& state, const CChainParams& chainparams, CBlockIndex * pindex);
182- bool ResetBlockFailureFlags (CBlockIndex * pindex);
180+ bool PreciousBlock (CValidationState& state, const CChainParams& params, CBlockIndex* pindex) LOCKS_EXCLUDED(cs_main );
181+ bool InvalidateBlock (CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main );
182+ bool ResetBlockFailureFlags (CBlockIndex* pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main );
183183
184184 bool ReplayBlocks (const CChainParams& params, CCoinsView* view);
185185 bool RewindBlockIndex (const CChainParams& params);
@@ -193,9 +193,9 @@ class CChainState {
193193 bool ActivateBestChainStep (CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexMostWork, const std::shared_ptr<const CBlock>& pblock, bool & fInvalidFound , ConnectTrace& connectTrace);
194194 bool ConnectTip (CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexNew, const std::shared_ptr<const CBlock>& pblock, ConnectTrace& connectTrace, DisconnectedBlockTransactions &disconnectpool);
195195
196- CBlockIndex* AddToBlockIndex (const CBlockHeader& block);
196+ CBlockIndex* AddToBlockIndex (const CBlockHeader& block) EXCLUSIVE_LOCKS_REQUIRED(cs_main) ;
197197 /* * Create a new block index entry for a given block hash */
198- CBlockIndex * InsertBlockIndex (const uint256& hash);
198+ CBlockIndex* InsertBlockIndex (const uint256& hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main );
199199 /* *
200200 * Make various assertions about the state of the block index.
201201 *
@@ -204,11 +204,11 @@ class CChainState {
204204 void CheckBlockIndex (const Consensus::Params& consensusParams);
205205
206206 void InvalidBlockFound (CBlockIndex *pindex, const CValidationState &state);
207- CBlockIndex* FindMostWorkChain ();
208- void ReceivedBlockTransactions (const CBlock& block, CBlockIndex* pindexNew, const CDiskBlockPos& pos, const Consensus::Params& consensusParams);
207+ CBlockIndex* FindMostWorkChain () EXCLUSIVE_LOCKS_REQUIRED(cs_main) ;
208+ void ReceivedBlockTransactions (const CBlock& block, CBlockIndex* pindexNew, const CDiskBlockPos& pos, const Consensus::Params& consensusParams) EXCLUSIVE_LOCKS_REQUIRED(cs_main) ;
209209
210210
211- bool RollforwardBlock (const CBlockIndex* pindex, CCoinsViewCache& inputs, const CChainParams& params);
211+ bool RollforwardBlock (const CBlockIndex* pindex, CCoinsViewCache& inputs, const CChainParams& params) EXCLUSIVE_LOCKS_REQUIRED(cs_main) ;
212212} g_chainstate;
213213
214214
@@ -2645,7 +2645,7 @@ bool CChainState::ActivateBestChainStep(CValidationState& state, const CChainPar
26452645 return true ;
26462646}
26472647
2648- static void NotifyHeaderTip () {
2648+ static void NotifyHeaderTip () LOCKS_EXCLUDED(cs_main) {
26492649 bool fNotify = false ;
26502650 bool fInitialBlockDownload = false ;
26512651 static CBlockIndex* pindexHeaderOld = nullptr ;
@@ -3395,7 +3395,7 @@ bool CChainState::AcceptBlockHeader(const CBlockHeader& block, CValidationState&
33953395 return error (" %s: Consensus::ContextualCheckBlockHeader: %s, %s" , __func__, hash.ToString (), FormatStateMessage (state));
33963396
33973397 // If the previous block index isn't valid, determine if it descends from any block which
3398- // has been found invalid (g_failed_blocks ), then mark pindexPrev and any blocks
3398+ // has been found invalid (m_failed_blocks ), then mark pindexPrev and any blocks
33993399 // between them as failed.
34003400 if (!pindexPrev->IsValid (BLOCK_VALID_SCRIPTS)) {
34013401 for (const CBlockIndex* failedit : m_failed_blocks) {
@@ -3826,7 +3826,7 @@ CBlockIndex * CChainState::InsertBlockIndex(const uint256& hash)
38263826
38273827bool CChainState::LoadBlockIndex (const Consensus::Params& consensus_params, CBlockTreeDB& blocktree)
38283828{
3829- if (!blocktree.LoadBlockIndexGuts (consensus_params, [this ](const uint256& hash){ return this ->InsertBlockIndex (hash); }))
3829+ if (!blocktree.LoadBlockIndexGuts (consensus_params, [this ](const uint256& hash) EXCLUSIVE_LOCKS_REQUIRED (cs_main) { return this ->InsertBlockIndex (hash); }))
38303830 return false ;
38313831
38323832 boost::this_thread::interruption_point ();
@@ -3876,7 +3876,7 @@ bool CChainState::LoadBlockIndex(const Consensus::Params& consensus_params, CBlo
38763876 return true ;
38773877}
38783878
3879- bool static LoadBlockIndexDB (const CChainParams& chainparams)
3879+ bool static LoadBlockIndexDB (const CChainParams& chainparams) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
38803880{
38813881 if (!g_chainstate.LoadBlockIndex (chainparams.GetConsensus (), *pblocktree))
38823882 return false ;
0 commit comments