@@ -157,16 +157,16 @@ class CChainState {
157
157
std::multimap<CBlockIndex*, CBlockIndex*> mapBlocksUnlinked;
158
158
CBlockIndex *pindexBestInvalid = nullptr ;
159
159
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) ;
161
161
162
162
bool ActivateBestChain (CValidationState &state, const CChainParams& chainparams, std::shared_ptr<const CBlock> pblock);
163
163
164
164
/* *
165
165
* If a block header hasn't already been seen, call CheckBlockHeader on it, ensure
166
166
* that it doesn't descend from an invalid block, and then add it to mapBlockIndex.
167
167
*/
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) ;
170
170
171
171
// Block (dis)connection on a given view:
172
172
DisconnectResult DisconnectBlock (const CBlock& block, const CBlockIndex* pindex, CCoinsViewCache& view);
@@ -177,9 +177,9 @@ class CChainState {
177
177
bool DisconnectTip (CValidationState& state, const CChainParams& chainparams, DisconnectedBlockTransactions *disconnectpool);
178
178
179
179
// 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 );
183
183
184
184
bool ReplayBlocks (const CChainParams& params, CCoinsView* view);
185
185
bool RewindBlockIndex (const CChainParams& params);
@@ -193,9 +193,9 @@ class CChainState {
193
193
bool ActivateBestChainStep (CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexMostWork, const std::shared_ptr<const CBlock>& pblock, bool & fInvalidFound , ConnectTrace& connectTrace);
194
194
bool ConnectTip (CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexNew, const std::shared_ptr<const CBlock>& pblock, ConnectTrace& connectTrace, DisconnectedBlockTransactions &disconnectpool);
195
195
196
- CBlockIndex* AddToBlockIndex (const CBlockHeader& block);
196
+ CBlockIndex* AddToBlockIndex (const CBlockHeader& block) EXCLUSIVE_LOCKS_REQUIRED(cs_main) ;
197
197
/* * 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 );
199
199
/* *
200
200
* Make various assertions about the state of the block index.
201
201
*
@@ -204,11 +204,11 @@ class CChainState {
204
204
void CheckBlockIndex (const Consensus::Params& consensusParams);
205
205
206
206
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) ;
209
209
210
210
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) ;
212
212
} g_chainstate;
213
213
214
214
@@ -2645,7 +2645,7 @@ bool CChainState::ActivateBestChainStep(CValidationState& state, const CChainPar
2645
2645
return true ;
2646
2646
}
2647
2647
2648
- static void NotifyHeaderTip () {
2648
+ static void NotifyHeaderTip () LOCKS_EXCLUDED(cs_main) {
2649
2649
bool fNotify = false ;
2650
2650
bool fInitialBlockDownload = false ;
2651
2651
static CBlockIndex* pindexHeaderOld = nullptr ;
@@ -3395,7 +3395,7 @@ bool CChainState::AcceptBlockHeader(const CBlockHeader& block, CValidationState&
3395
3395
return error (" %s: Consensus::ContextualCheckBlockHeader: %s, %s" , __func__, hash.ToString (), FormatStateMessage (state));
3396
3396
3397
3397
// 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
3399
3399
// between them as failed.
3400
3400
if (!pindexPrev->IsValid (BLOCK_VALID_SCRIPTS)) {
3401
3401
for (const CBlockIndex* failedit : m_failed_blocks) {
@@ -3826,7 +3826,7 @@ CBlockIndex * CChainState::InsertBlockIndex(const uint256& hash)
3826
3826
3827
3827
bool CChainState::LoadBlockIndex (const Consensus::Params& consensus_params, CBlockTreeDB& blocktree)
3828
3828
{
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); }))
3830
3830
return false ;
3831
3831
3832
3832
boost::this_thread::interruption_point ();
@@ -3876,7 +3876,7 @@ bool CChainState::LoadBlockIndex(const Consensus::Params& consensus_params, CBlo
3876
3876
return true ;
3877
3877
}
3878
3878
3879
- bool static LoadBlockIndexDB (const CChainParams& chainparams)
3879
+ bool static LoadBlockIndexDB (const CChainParams& chainparams) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
3880
3880
{
3881
3881
if (!g_chainstate.LoadBlockIndex (chainparams.GetConsensus (), *pblocktree))
3882
3882
return false ;
0 commit comments