From f4502099a40c06cac59b420d753f8066a4196845 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Thu, 7 Dec 2017 12:42:47 +0300 Subject: [PATCH] make CheckDSTXes() private, execute it on both client and server (#1736) --- src/dsnotificationinterface.cpp | 1 + src/privatesend-client.cpp | 2 +- src/privatesend.cpp | 7 +++++++ src/privatesend.h | 5 ++++- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/dsnotificationinterface.cpp b/src/dsnotificationinterface.cpp index 809c90496..b4d56944d 100644 --- a/src/dsnotificationinterface.cpp +++ b/src/dsnotificationinterface.cpp @@ -65,6 +65,7 @@ void CDSNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, con return; mnodeman.UpdatedBlockTip(pindexNew); + CPrivateSend::UpdatedBlockTip(pindexNew); #ifdef ENABLE_WALLET privateSendClient.UpdatedBlockTip(pindexNew); #endif // ENABLE_WALLET diff --git a/src/privatesend-client.cpp b/src/privatesend-client.cpp index 52e5c619b..58f1534d0 100644 --- a/src/privatesend-client.cpp +++ b/src/privatesend-client.cpp @@ -1391,13 +1391,13 @@ void CPrivateSendClient::UpdatedBlockTip(const CBlockIndex *pindex) nCachedBlockHeight = pindex->nHeight; LogPrint("privatesend", "CPrivateSendClient::UpdatedBlockTip -- nCachedBlockHeight: %d\n", nCachedBlockHeight); - CPrivateSend::CheckDSTXes(pindex->nHeight); } //TODO: Rename/move to core void ThreadCheckPrivateSendClient(CConnman& connman) { if(fLiteMode) return; // disable all Dash specific functionality + if(fMasterNode) return; // no client-side mixing on masternodes static bool fOneThread; if(fOneThread) return; diff --git a/src/privatesend.cpp b/src/privatesend.cpp index bdefce1a3..a0129ae6d 100644 --- a/src/privatesend.cpp +++ b/src/privatesend.cpp @@ -403,6 +403,13 @@ void CPrivateSend::CheckDSTXes(int nHeight) LogPrint("privatesend", "CPrivateSend::CheckDSTXes -- mapDSTX.size()=%llu\n", mapDSTX.size()); } +void CPrivateSend::UpdatedBlockTip(const CBlockIndex *pindex) +{ + if(pindex && !fLiteMode && masternodeSync.IsMasternodeListSynced()) { + CheckDSTXes(pindex->nHeight); + } +} + void CPrivateSend::SyncTransaction(const CTransaction& tx, const CBlock* pblock) { if (tx.IsCoinBase()) return; diff --git a/src/privatesend.h b/src/privatesend.h index 2eff19431..8f78c7af0 100644 --- a/src/privatesend.h +++ b/src/privatesend.h @@ -5,6 +5,7 @@ #ifndef PRIVATESEND_H #define PRIVATESEND_H +#include "chain.h" #include "chainparams.h" #include "primitives/transaction.h" #include "pubkey.h" @@ -317,6 +318,8 @@ private: static CCriticalSection cs_mapdstx; + static void CheckDSTXes(int nHeight); + public: static void InitStandardDenominations(); static std::vector GetStandardDenominations() { return vecStandardDenominations; } @@ -348,8 +351,8 @@ public: static void AddDSTX(const CDarksendBroadcastTx& dstx); static CDarksendBroadcastTx GetDSTX(const uint256& hash); - static void CheckDSTXes(int nHeight); + static void UpdatedBlockTip(const CBlockIndex *pindex); static void SyncTransaction(const CTransaction& tx, const CBlock* pblock); };