@@ -1634,13 +1634,8 @@ CDeterministicMNManager::RecalcDiffsResult CDeterministicMNManager::RecalculateA
16341634 CDeterministicMNList from_snapshot;
16351635 CDeterministicMNList to_snapshot;
16361636
1637- bool has_from_snapshot;
1638- bool has_to_snapshot;
1639- {
1640- LOCK (cs);
1641- has_from_snapshot = m_evoDb.Read (std::make_pair (DB_LIST_SNAPSHOT, from_index->GetBlockHash ()), from_snapshot);
1642- has_to_snapshot = m_evoDb.Read (std::make_pair (DB_LIST_SNAPSHOT, to_index->GetBlockHash ()), to_snapshot);
1643- }
1637+ bool has_from_snapshot = m_evoDb.Read (std::make_pair (DB_LIST_SNAPSHOT, from_index->GetBlockHash ()), from_snapshot);
1638+ bool has_to_snapshot = m_evoDb.Read (std::make_pair (DB_LIST_SNAPSHOT, to_index->GetBlockHash ()), to_snapshot);
16441639
16451640 // Handle missing snapshots
16461641 if (!has_from_snapshot) {
@@ -1667,11 +1662,7 @@ CDeterministicMNManager::RecalcDiffsResult CDeterministicMNManager::RecalculateA
16671662 }
16681663
16691664 // Verify this snapshot pair
1670- bool is_snapshot_pair_valid;
1671- {
1672- LOCK (cs);
1673- is_snapshot_pair_valid = VerifySnapshotPair (from_index, to_index, from_snapshot, to_snapshot, result, i, snapshot_blocks.size () - 1 );
1674- }
1665+ bool is_snapshot_pair_valid = VerifySnapshotPair (from_index, to_index, from_snapshot, to_snapshot, result, i, snapshot_blocks.size () - 1 );
16751666
16761667 // If repair mode is enabled and verification failed, recalculate diffs from blockchain
16771668 if (repair && !is_snapshot_pair_valid) {
@@ -1688,7 +1679,6 @@ CDeterministicMNManager::RecalcDiffsResult CDeterministicMNManager::RecalculateA
16881679
16891680 // Write repaired diffs to database
16901681 if (repair) {
1691- LOCK (cs);
16921682 WriteRepairedDiffs (recalculated_diffs, result);
16931683 }
16941684
@@ -1751,7 +1741,6 @@ bool CDeterministicMNManager::VerifySnapshotPair(
17511741 const CBlockIndex* from_index, const CBlockIndex* to_index, const CDeterministicMNList& from_snapshot,
17521742 const CDeterministicMNList& to_snapshot, RecalcDiffsResult& result, size_t pair_index, size_t total_pairs)
17531743{
1754- AssertLockHeld (cs);
17551744 AssertLockHeld (::cs_main);
17561745
17571746 // Log progress periodically (every 100 snapshot pairs) to avoid spam
@@ -1879,7 +1868,7 @@ std::vector<std::pair<uint256, CDeterministicMNListDiff>> CDeterministicMNManage
18791868void CDeterministicMNManager::WriteRepairedDiffs (
18801869 const std::vector<std::pair<uint256, CDeterministicMNListDiff>>& recalculated_diffs, RecalcDiffsResult& result)
18811870{
1882- AssertLockHeld (cs);
1871+ AssertLockNotHeld (cs);
18831872
18841873 if (recalculated_diffs.empty ()) {
18851874 return ;
@@ -1914,6 +1903,7 @@ void CDeterministicMNManager::WriteRepairedDiffs(
19141903
19151904 // Clear caches for repaired diffs so next read gets fresh data from disk
19161905 // Must clear both diff cache and list cache since lists were built from old diffs
1906+ LOCK (cs);
19171907 for (const auto & [block_hash, diff] : recalculated_diffs) {
19181908 mnListDiffsCache.erase (block_hash);
19191909 mnListsCache.erase (block_hash);
0 commit comments