From 9c10ede1371d8573e216f627cddcb18f6e7c9820 Mon Sep 17 00:00:00 2001 From: "James C. Owens" Date: Sun, 17 Sep 2023 12:43:34 -0400 Subject: [PATCH] Add static locking analysis keywords to CheckBlock and WriteBlockToDisk. --- src/node/blockstorage.cpp | 3 +++ src/validation.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/node/blockstorage.cpp b/src/node/blockstorage.cpp index f491b723a8..502686fa9f 100644 --- a/src/node/blockstorage.cpp +++ b/src/node/blockstorage.cpp @@ -15,7 +15,10 @@ bool WriteBlockToDisk(const CBlock& block, unsigned int& nFileRet, unsigned int& nBlockPosRet, const CMessageHeader::MessageStartChars& messageStart) + EXCLUSIVE_LOCKS_REQUIRED(cs_main) { + AssertLockHeld(cs_main); + // Open history file to append CAutoFile fileout(AppendBlockFile(nFileRet), SER_DISK, CLIENT_VERSION); if (fileout.IsNull()) diff --git a/src/validation.cpp b/src/validation.cpp index 775dc60181..ee78d93bf5 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1752,7 +1752,10 @@ bool AddToBlockIndex(CBlock& block, unsigned int nFile, unsigned int nBlockPos, } bool CheckBlock(const CBlock& block, int height1, bool fCheckPOW, bool fCheckMerkleRoot, bool fCheckSig, bool fLoadingIndex) + EXCLUSIVE_LOCKS_REQUIRED(cs_main) { + AssertLockHeld(cs_main); + // Allow the genesis block to pass. if(block.hashPrevBlock.IsNull() && block.GetHash(true) == (fTestNet ? hashGenesisBlockTestNet : hashGenesisBlock))