Skip to content

Commit ddeefee

Browse files
w0xlthebasto
andcommitted
refactor: add negative TS annotations for m_chainstate_mutex
Co-authored-by: Hennadii Stepanov <[email protected]>
1 parent 1dfd31b commit ddeefee

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/validation.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2821,6 +2821,8 @@ static void LimitValidationInterfaceQueue() LOCKS_EXCLUDED(cs_main) {
28212821

28222822
bool CChainState::ActivateBestChain(BlockValidationState& state, std::shared_ptr<const CBlock> pblock)
28232823
{
2824+
AssertLockNotHeld(m_chainstate_mutex);
2825+
28242826
// Note that while we're often called here from ProcessNewBlock, this is
28252827
// far from a guarantee. Things in the P2P/RPC will often end up calling
28262828
// us in the middle of ProcessNewBlock - do not assume pblock is set
@@ -2950,6 +2952,8 @@ bool CChainState::PreciousBlock(BlockValidationState& state, CBlockIndex* pindex
29502952

29512953
bool CChainState::InvalidateBlock(BlockValidationState& state, CBlockIndex* pindex)
29522954
{
2955+
AssertLockNotHeld(m_chainstate_mutex);
2956+
29532957
// Genesis block can't be invalidated
29542958
assert(pindex);
29552959
if (pindex->nHeight == 0) return false;

src/validation.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ class CChainState
700700
*/
701701
bool ActivateBestChain(
702702
BlockValidationState& state,
703-
std::shared_ptr<const CBlock> pblock = nullptr) LOCKS_EXCLUDED(cs_main);
703+
std::shared_ptr<const CBlock> pblock = nullptr) LOCKS_EXCLUDED(m_chainstate_mutex, cs_main);
704704

705705
bool AcceptBlock(const std::shared_ptr<const CBlock>& pblock, BlockValidationState& state, CBlockIndex** ppindex, bool fRequested, const FlatFilePos* dbp, bool* fNewBlock) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
706706

@@ -720,7 +720,7 @@ class CChainState
720720
*/
721721
bool PreciousBlock(BlockValidationState& state, CBlockIndex* pindex) LOCKS_EXCLUDED(cs_main);
722722
/** Mark a block as invalid. */
723-
bool InvalidateBlock(BlockValidationState& state, CBlockIndex* pindex) LOCKS_EXCLUDED(cs_main);
723+
bool InvalidateBlock(BlockValidationState& state, CBlockIndex* pindex) LOCKS_EXCLUDED(m_chainstate_mutex, cs_main);
724724
/** Remove invalidity status from a block and its descendants. */
725725
void ResetBlockFailureFlags(CBlockIndex* pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
726726

0 commit comments

Comments
 (0)