@@ -87,50 +87,6 @@ bool CheckCbTxMerkleRoots(const CBlock& block, const CCbTx& cbTx, const CBlockIn
8787 return true ;
8888}
8989
90- bool CalcCbTxMerkleRootMNList (uint256& merkleRootRet, CSimplifiedMNList&& sml, BlockValidationState& state)
91- {
92- try {
93- static std::atomic<int64_t > nTimeMerkle = 0 ;
94-
95- int64_t nTime1 = GetTimeMicros ();
96-
97- static Mutex cached_mutex;
98- static CSimplifiedMNList smlCached GUARDED_BY (cached_mutex);
99- static uint256 merkleRootCached GUARDED_BY (cached_mutex);
100- static bool mutatedCached GUARDED_BY (cached_mutex) {false };
101-
102- LOCK (cached_mutex);
103- if (sml == smlCached) {
104- merkleRootRet = merkleRootCached;
105- if (mutatedCached) {
106- return state.Invalid (BlockValidationResult::BLOCK_CONSENSUS, " mutated-cached-calc-cb-mnmerkleroot" );
107- }
108- return true ;
109- }
110-
111- bool mutated = false ;
112- merkleRootRet = sml.CalcMerkleRoot (&mutated);
113-
114- int64_t nTime2 = GetTimeMicros ();
115- nTimeMerkle += nTime2 - nTime1;
116- LogPrint (BCLog::BENCHMARK, " - CalcMerkleRoot: %.2fms [%.2fs]\n " , 0.001 * (nTime2 - nTime1),
117- nTimeMerkle * 0.000001 );
118-
119- smlCached = std::move (sml);
120- merkleRootCached = merkleRootRet;
121- mutatedCached = mutated;
122-
123- if (mutated) {
124- return state.Invalid (BlockValidationResult::BLOCK_CONSENSUS, " mutated-calc-cb-mnmerkleroot" );
125- }
126-
127- return true ;
128- } catch (const std::exception& e) {
129- LogPrintf (" %s -- failed: %s\n " , __func__, e.what ());
130- return state.Invalid (BlockValidationResult::BLOCK_CONSENSUS, " failed-calc-cb-mnmerkleroot" );
131- }
132- }
133-
13490using QcHashMap = std::map<Consensus::LLMQType, std::vector<uint256>>;
13591using QcIndexedHashMap = std::map<Consensus::LLMQType, std::map<int16_t , uint256>>;
13692
0 commit comments