From 271c249e154ca4b9b9d290e5e6bd2316769c36ab Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Mon, 12 Feb 2018 15:47:20 +0300 Subject: [PATCH] Skip next mn payments winners when selecting a MN to mix on (#1921) --- src/masternode-payments.cpp | 4 ++-- src/masternode-payments.h | 2 +- src/privatesend-client.cpp | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/masternode-payments.cpp b/src/masternode-payments.cpp index f7ed617f7..2fbbc274f 100644 --- a/src/masternode-payments.cpp +++ b/src/masternode-payments.cpp @@ -427,14 +427,14 @@ bool CMasternodePayments::GetBlockPayee(int nBlockHeight, CScript& payee) // Is this masternode scheduled to get paid soon? // -- Only look ahead up to 8 blocks to allow for propagation of the latest 2 blocks of votes -bool CMasternodePayments::IsScheduled(const CMasternode& mn, int nNotBlockHeight) +bool CMasternodePayments::IsScheduled(const masternode_info_t& mnInfo, int nNotBlockHeight) { LOCK(cs_mapMasternodeBlocks); if(!masternodeSync.IsMasternodeListSynced()) return false; CScript mnpayee; - mnpayee = GetScriptForDestination(mn.pubKeyCollateralAddress.GetID()); + mnpayee = GetScriptForDestination(mnInfo.pubKeyCollateralAddress.GetID()); CScript payee; for(int64_t h = nCachedBlockHeight; h <= nCachedBlockHeight + 8; h++){ diff --git a/src/masternode-payments.h b/src/masternode-payments.h index a9830dcb5..518e67aa5 100644 --- a/src/masternode-payments.h +++ b/src/masternode-payments.h @@ -204,7 +204,7 @@ public: bool GetBlockPayee(int nBlockHeight, CScript& payee); bool IsTransactionValid(const CTransaction& txNew, int nBlockHeight); - bool IsScheduled(const CMasternode& mn, int nNotBlockHeight); + bool IsScheduled(const masternode_info_t& mnInfo, int nNotBlockHeight); bool CanVote(COutPoint outMasternode, int nBlockHeight); diff --git a/src/privatesend-client.cpp b/src/privatesend-client.cpp index 26f891d4c..412b5c8ee 100644 --- a/src/privatesend-client.cpp +++ b/src/privatesend-client.cpp @@ -7,6 +7,7 @@ #include "consensus/validation.h" #include "core_io.h" #include "init.h" +#include "masternode-payments.h" #include "masternode-sync.h" #include "masternodeman.h" #include "netmessagemaker.h" @@ -852,6 +853,12 @@ bool CPrivateSendClient::JoinExistingQueue(CAmount nBalanceNeedsAnonymized, CCon if(infoMn.nProtocolVersion < MIN_PRIVATESEND_PEER_PROTO_VERSION) continue; + // skip next mn payments winners + if (mnpayments.IsScheduled(infoMn, 0)) { + LogPrintf("CPrivateSendClient::JoinExistingQueue -- skipping winner, masternode=%s\n", infoMn.vin.prevout.ToStringShort()); + continue; + } + std::vector vecBits; if(!CPrivateSend::GetDenominationsBits(dsq.nDenom, vecBits)) { // incompatible denom @@ -915,11 +922,20 @@ bool CPrivateSendClient::StartNewQueue(CAmount nValueMin, CAmount nBalanceNeedsA // otherwise, try one randomly while(nTries < 10) { masternode_info_t infoMn = mnodeman.FindRandomNotInVec(vecMasternodesUsed, MIN_PRIVATESEND_PEER_PROTO_VERSION); + if(!infoMn.fInfoValid) { LogPrintf("CPrivateSendClient::StartNewQueue -- Can't find random masternode!\n"); strAutoDenomResult = _("Can't find random Masternode."); return false; } + + // skip next mn payments winners + if (mnpayments.IsScheduled(infoMn, 0)) { + LogPrintf("CPrivateSendClient::StartNewQueue -- skipping winner, masternode=%s\n", infoMn.vin.prevout.ToStringShort()); + nTries++; + continue; + } + vecMasternodesUsed.push_back(infoMn.vin.prevout); if(infoMn.nLastDsq != 0 && infoMn.nLastDsq + nMnCountEnabled/5 > mnodeman.nDsqCount) {