mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Fix potential deadlock in CInstantSendDb::Upgrade()
(#4548)
This commit is contained in:
parent
db77905703
commit
95262de6b1
@ -58,8 +58,11 @@ CInstantSendDb::CInstantSendDb(bool unitTests, bool fWipe)
|
||||
db = std::make_unique<CDBWrapper>(unitTests ? "" : (GetDataDir() / "llmq/isdb"), 32 << 20, unitTests, fWipe);
|
||||
}
|
||||
|
||||
void CInstantSendDb::Upgrade()
|
||||
void CInstantSendDb::Upgrade() EXCLUSIVE_LOCKS_REQUIRED(cs_main, ::mempool.cs)
|
||||
{
|
||||
AssertLockHeld(cs_main);
|
||||
AssertLockHeld(::mempool.cs);
|
||||
|
||||
LOCK(cs_db);
|
||||
int v{0};
|
||||
if (!db->Read(DB_VERSION, v) || v < CInstantSendDb::CURRENT_VERSION) {
|
||||
@ -1267,7 +1270,7 @@ void CInstantSendManager::NotifyChainLock(const CBlockIndex* pindexChainLock)
|
||||
void CInstantSendManager::UpdatedBlockTip(const CBlockIndex* pindexNew)
|
||||
{
|
||||
if (!fUpgradedDB) {
|
||||
LOCK(cs_main);
|
||||
LOCK2(cs_main, ::mempool.cs); // for GetTransaction in Upgrade
|
||||
if (VersionBitsState(pindexNew, Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0020, versionbitscache) == ThresholdState::ACTIVE) {
|
||||
db.Upgrade();
|
||||
fUpgradedDB = true;
|
||||
|
Loading…
Reference in New Issue
Block a user