mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
instantsend: Postpone mempool related cleanup fixes until dip0020 activation (#4159)
* instantsend: Upgrade IS db on dip0020 activation * instantsend: Do not remove islocks for txes removed from mempool until dip0020 is activated * refactor: introduce fUpgradedDB to avoid excessive locking and checking the state * llmq: Decouple `fUpgradedDB` from `cs` * Update src/llmq/quorums_instantsend.cpp Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> * Fix deadlock Upgrade locks cs_main via GetTransaction Co-authored-by: xdustinface <xdustinfacex@gmail.com> Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>
This commit is contained in:
parent
0e3aea8c4e
commit
8b831eeb7e
@ -49,7 +49,6 @@ uint256 CInstantSendLock::GetRequestId() const
|
||||
|
||||
CInstantSendDb::CInstantSendDb(CDBWrapper& _db) : db(_db)
|
||||
{
|
||||
Upgrade();
|
||||
}
|
||||
|
||||
void CInstantSendDb::Upgrade()
|
||||
@ -1069,7 +1068,7 @@ void CInstantSendManager::TransactionAddedToMempool(const CTransactionRef& tx)
|
||||
|
||||
void CInstantSendManager::TransactionRemovedFromMempool(const CTransactionRef& tx)
|
||||
{
|
||||
if (tx->vin.empty()) {
|
||||
if (tx->vin.empty() || !fUpgradedDB) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1214,6 +1213,14 @@ void CInstantSendManager::NotifyChainLock(const CBlockIndex* pindexChainLock)
|
||||
|
||||
void CInstantSendManager::UpdatedBlockTip(const CBlockIndex* pindexNew)
|
||||
{
|
||||
if (!fUpgradedDB) {
|
||||
LOCK(cs_main);
|
||||
if (VersionBitsState(pindexNew, Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0020, versionbitscache) == ThresholdState::ACTIVE) {
|
||||
db.Upgrade();
|
||||
fUpgradedDB = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool fDIP0008Active = pindexNew->pprev && pindexNew->pprev->nHeight >= Params().GetConsensus().DIP0008Height;
|
||||
|
||||
if (AreChainLocksEnabled() && fDIP0008Active) {
|
||||
|
@ -54,11 +54,11 @@ private:
|
||||
void WriteInstantSendLockMined(CDBBatch& batch, const uint256& hash, int nHeight);
|
||||
void RemoveInstantSendLockMined(CDBBatch& batch, const uint256& hash, int nHeight);
|
||||
|
||||
void Upgrade();
|
||||
|
||||
public:
|
||||
explicit CInstantSendDb(CDBWrapper& _db);
|
||||
|
||||
void Upgrade();
|
||||
|
||||
void WriteNewInstantSendLock(const uint256& hash, const CInstantSendLock& islock);
|
||||
void RemoveInstantSendLock(CDBBatch& batch, const uint256& hash, CInstantSendLockPtr islock, bool keep_cache = true);
|
||||
|
||||
@ -86,6 +86,8 @@ private:
|
||||
mutable CCriticalSection cs;
|
||||
CInstantSendDb db;
|
||||
|
||||
std::atomic<bool> fUpgradedDB{false};
|
||||
|
||||
std::thread workThread;
|
||||
CThreadInterrupt workInterrupt;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user