mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
remove DS mixes once they have been included in a chainlocked block (#3015)
* remove DS mixes once they have been included in a chainlocked block Signed-off-by: Pasta <pasta@dashboost.org> * Use multiple if checks instead of one line conditional Signed-off-by: Pasta <pasta@dashboost.org>
This commit is contained in:
parent
54ab2048ca
commit
bdec34c949
@ -17,6 +17,7 @@
|
||||
#include "validation.h"
|
||||
|
||||
#include "llmq/quorums_instantsend.h"
|
||||
#include "llmq/quorums_chainlocks.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
@ -115,10 +116,12 @@ bool CPrivateSendBroadcastTx::CheckSignature(const CBLSPublicKey& blsPubKey) con
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPrivateSendBroadcastTx::IsExpired(int nHeight)
|
||||
bool CPrivateSendBroadcastTx::IsExpired(const CBlockIndex* pindex)
|
||||
{
|
||||
// expire confirmed DSTXes after ~1h since confirmation
|
||||
return (nConfirmedHeight != -1) && (nHeight - nConfirmedHeight > 24);
|
||||
// expire confirmed DSTXes after ~1h since confirmation or chainlocked confirmation
|
||||
if (nConfirmedHeight == -1 || pindex->nHeight < nConfirmedHeight) return false; // not mined yet
|
||||
if (pindex->nHeight - nConfirmedHeight > 24) return true; // mined more then an hour ago
|
||||
return llmq::chainLocksHandler->HasChainLock(pindex->nHeight, *pindex->phashBlock);
|
||||
}
|
||||
|
||||
bool CPrivateSendBroadcastTx::IsValidStructure()
|
||||
@ -487,12 +490,12 @@ CPrivateSendBroadcastTx CPrivateSend::GetDSTX(const uint256& hash)
|
||||
return (it == mapDSTX.end()) ? CPrivateSendBroadcastTx() : it->second;
|
||||
}
|
||||
|
||||
void CPrivateSend::CheckDSTXes(int nHeight)
|
||||
void CPrivateSend::CheckDSTXes(const CBlockIndex* pindex)
|
||||
{
|
||||
LOCK(cs_mapdstx);
|
||||
auto it = mapDSTX.begin();
|
||||
while (it != mapDSTX.end()) {
|
||||
if (it->second.IsExpired(nHeight)) {
|
||||
if (it->second.IsExpired(pindex)) {
|
||||
mapDSTX.erase(it++);
|
||||
} else {
|
||||
++it;
|
||||
@ -504,7 +507,7 @@ void CPrivateSend::CheckDSTXes(int nHeight)
|
||||
void CPrivateSend::UpdatedBlockTip(const CBlockIndex* pindex)
|
||||
{
|
||||
if (pindex && masternodeSync.IsBlockchainSynced()) {
|
||||
CheckDSTXes(pindex->nHeight);
|
||||
CheckDSTXes(pindex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -351,7 +351,7 @@ public:
|
||||
bool CheckSignature(const CBLSPublicKey& blsPubKey) const;
|
||||
|
||||
void SetConfirmedHeight(int nConfirmedHeightIn) { nConfirmedHeight = nConfirmedHeightIn; }
|
||||
bool IsExpired(int nHeight);
|
||||
bool IsExpired(const CBlockIndex* pindex);
|
||||
bool IsValidStructure();
|
||||
};
|
||||
|
||||
@ -427,7 +427,7 @@ private:
|
||||
|
||||
static CCriticalSection cs_mapdstx;
|
||||
|
||||
static void CheckDSTXes(int nHeight);
|
||||
static void CheckDSTXes(const CBlockIndex* pindex);
|
||||
|
||||
public:
|
||||
static void InitStandardDenominations();
|
||||
|
Loading…
Reference in New Issue
Block a user