1616#include < bls/bls.h>
1717#include < chainlock/chainlock.h>
1818#include < instantsend/instantsend.h>
19- #include < masternode/sync.h>
2019
2120#include < string>
2221
@@ -81,13 +80,6 @@ bool CCoinJoinBroadcastTx::CheckSignature(const CBLSPublicKey& blsPubKey) const
8180 return true ;
8281}
8382
84- bool CCoinJoinBroadcastTx::IsExpired (const CBlockIndex* pindex) const
85- {
86- // expire confirmed DSTXes after ~1h since confirmation
87- if (!nConfirmedHeight.has_value () || pindex->nHeight < *nConfirmedHeight) return false ; // not mined yet
88- return (pindex->nHeight - *nConfirmedHeight > 24 ); // mined more than an hour ago
89- }
90-
9183bool CCoinJoinBroadcastTx::IsValidStructure () const
9284{
9385 // some trivial checks only
@@ -415,13 +407,22 @@ CCoinJoinBroadcastTx CDSTXManager::GetDSTX(const uint256& hash)
415407 return (it == mapDSTX.end ()) ? CCoinJoinBroadcastTx () : it->second ;
416408}
417409
410+ bool CDSTXManager::IsTxExpired (const CCoinJoinBroadcastTx& tx, const CBlockIndex* pindex) const
411+ {
412+ // expire confirmed DSTXes after ~1h since confirmation or chainlocked
413+ const auto & opt_confirmed_height = tx.GetConfirmedHeight ();
414+ if (!opt_confirmed_height.has_value () || pindex->nHeight < *opt_confirmed_height) return false ; // not mined yet
415+ return (pindex->nHeight - *opt_confirmed_height > 24 ) ||
416+ m_chainlocks.HasChainLock (pindex->nHeight , *pindex->phashBlock ); // mined more than an hour ago or chainlocked
417+ }
418+
418419void CDSTXManager::CheckDSTXes (const CBlockIndex* pindex)
419420{
420421 AssertLockNotHeld (cs_mapdstx);
421422 LOCK (cs_mapdstx);
422423 auto it = mapDSTX.begin ();
423424 while (it != mapDSTX.end ()) {
424- if (it->second . IsExpired (pindex) || m_chainlocks. HasChainLock (pindex-> nHeight , * pindex-> phashBlock )) {
425+ if (IsTxExpired ( it->second , pindex)) {
425426 mapDSTX.erase (it++);
426427 } else {
427428 ++it;
@@ -430,16 +431,16 @@ void CDSTXManager::CheckDSTXes(const CBlockIndex* pindex)
430431 LogPrint (BCLog::COINJOIN , " CoinJoin::CheckDSTXes -- mapDSTX.size()=%llu\n " , mapDSTX.size ());
431432}
432433
433- void CDSTXManager::UpdatedBlockTip (const CBlockIndex* pindex, const CMasternodeSync& mn_sync )
434+ void CDSTXManager::UpdatedBlockTip (const CBlockIndex* pindex)
434435{
435- if (pindex && mn_sync. IsBlockchainSynced () ) {
436+ if (pindex) {
436437 CheckDSTXes (pindex);
437438 }
438439}
439440
440- void CDSTXManager::NotifyChainLock (const CBlockIndex* pindex, const CMasternodeSync& mn_sync )
441+ void CDSTXManager::NotifyChainLock (const CBlockIndex* pindex)
441442{
442- if (pindex && mn_sync. IsBlockchainSynced () ) {
443+ if (pindex) {
443444 CheckDSTXes (pindex);
444445 }
445446}
0 commit comments