Skip to content

Commit f482f01

Browse files
committed
fix: drop redundant thread safety annotations
1 parent 6df3a7c commit f482f01

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

src/evo/deterministicmns.cpp

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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
18791868
void 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);

src/evo/deterministicmns.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -758,13 +758,13 @@ class CDeterministicMNManager
758758
const Consensus::Params& consensus_params) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
759759
bool VerifySnapshotPair(const CBlockIndex* from_index, const CBlockIndex* to_index, const CDeterministicMNList& from_snapshot,
760760
const CDeterministicMNList& to_snapshot, RecalcDiffsResult& result, size_t pair_index,
761-
size_t total_pairs) EXCLUSIVE_LOCKS_REQUIRED(cs, ::cs_main);
761+
size_t total_pairs) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
762762
std::vector<std::pair<uint256, CDeterministicMNListDiff>> RepairSnapshotPair(
763763
const CBlockIndex* from_index, const CBlockIndex* to_index, const CDeterministicMNList& from_snapshot,
764764
const CDeterministicMNList& to_snapshot, BuildListFromBlockFunc build_list_func, RecalcDiffsResult& result)
765765
EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
766766
void WriteRepairedDiffs(const std::vector<std::pair<uint256, CDeterministicMNListDiff>>& recalculated_diffs,
767-
RecalcDiffsResult& result) EXCLUSIVE_LOCKS_REQUIRED(cs);
767+
RecalcDiffsResult& result) EXCLUSIVE_LOCKS_REQUIRED(!cs);
768768
};
769769

770770
bool CheckProRegTx(CDeterministicMNManager& dmnman, const CTransaction& tx, gsl::not_null<const CBlockIndex*> pindexPrev, TxValidationState& state, const CCoinsViewCache& view, bool check_sigs);

0 commit comments

Comments
 (0)