From 8b0c0493ac175cb12c039407489f3f2e37423d8a Mon Sep 17 00:00:00 2001 From: Duke Date: Thu, 12 Sep 2024 19:47:42 -0400 Subject: [PATCH] Ensure cs_main lock is held when TestBlockValidity() is called --- src/miner.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/miner.cpp b/src/miner.cpp index 436a59262..6bc205ed4 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1334,6 +1334,8 @@ void static RandomXMiner() } CValidationState state; + { LOCK(cs_main); + if ( !TestBlockValidity(state,B, chainActive.LastTip(), true, false)) { h = UintToArith256(B.GetHash()); @@ -1344,6 +1346,8 @@ void static RandomXMiner() fprintf(stderr,"\n"); return(false); } + + } SetThreadPriority(THREAD_PRIORITY_NORMAL); LogPrintf("HushRandomXMiner:\n"); LogPrintf("proof-of-work found \n hash: %s \ntarget: %s\n", B.GetHash().GetHex(), HASHTarget.GetHex()); @@ -1702,6 +1706,8 @@ void static BitcoinMiner() fprintf(stderr," mined %s block %d!\n",SMART_CHAIN_SYMBOL,Mining_height); } CValidationState state; + { LOCK(cs_main); + if ( !TestBlockValidity(state,B, chainActive.LastTip(), true, false)) { h = UintToArith256(B.GetHash()); @@ -1711,6 +1717,8 @@ void static BitcoinMiner() gotinvalid = 1; return(false); } + + } HUSH_CHOSEN_ONE = 1; // Found a solution SetThreadPriority(THREAD_PRIORITY_NORMAL);