mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-06-02 15:32:34 +02:00
rpc/blockchain.cpp: Remove g_utxosetscan mutex that is only protecting a single atomic variable
This commit is contained in:
parent
d96fdc2a39
commit
c3cf2f5501
@ -1976,7 +1976,6 @@ bool FindScriptPubKey(std::atomic<int>& scan_progress, const std::atomic<bool>&
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** RAII object to prevent concurrency issue when scanning the txout set */
|
/** RAII object to prevent concurrency issue when scanning the txout set */
|
||||||
static std::mutex g_utxosetscan;
|
|
||||||
static std::atomic<int> g_scan_progress;
|
static std::atomic<int> g_scan_progress;
|
||||||
static std::atomic<bool> g_scan_in_progress;
|
static std::atomic<bool> g_scan_in_progress;
|
||||||
static std::atomic<bool> g_should_abort_scan;
|
static std::atomic<bool> g_should_abort_scan;
|
||||||
@ -1989,18 +1988,15 @@ public:
|
|||||||
|
|
||||||
bool reserve() {
|
bool reserve() {
|
||||||
CHECK_NONFATAL(!m_could_reserve);
|
CHECK_NONFATAL(!m_could_reserve);
|
||||||
std::lock_guard<std::mutex> lock(g_utxosetscan);
|
if (g_scan_in_progress.exchange(true)) {
|
||||||
if (g_scan_in_progress) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
g_scan_in_progress = true;
|
|
||||||
m_could_reserve = true;
|
m_could_reserve = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
~CoinsViewScanReserver() {
|
~CoinsViewScanReserver() {
|
||||||
if (m_could_reserve) {
|
if (m_could_reserve) {
|
||||||
std::lock_guard<std::mutex> lock(g_utxosetscan);
|
|
||||||
g_scan_in_progress = false;
|
g_scan_in_progress = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user