Skip to content

Commit 6ff4331

Browse files
UdjinM6CryptoCentric
authored andcommitted
Skip next mn payments winners when selecting a MN to mix on (dashpay#1921)
1 parent 7f74725 commit 6ff4331

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

src/masternode-payments.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,14 +448,14 @@ bool CMasternodePayments::GetBlockPayee(int nBlockHeight, CScript& payee)
448448

449449
// Is this masternode scheduled to get paid soon?
450450
// -- Only look ahead up to 8 blocks to allow for propagation of the latest 2 blocks of votes
451-
bool CMasternodePayments::IsScheduled(const CMasternode& mn, int nNotBlockHeight)
451+
bool CMasternodePayments::IsScheduled(const masternode_info_t& mnInfo, int nNotBlockHeight)
452452
{
453453
LOCK(cs_mapMasternodeBlocks);
454454

455455
if(!masternodeSync.IsMasternodeListSynced()) return false;
456456

457457
CScript mnpayee;
458-
mnpayee = GetScriptForDestination(mn.pubKeyCollateralAddress.GetID());
458+
mnpayee = GetScriptForDestination(mnInfo.pubKeyCollateralAddress.GetID());
459459

460460
CScript payee;
461461
for(int64_t h = nCachedBlockHeight; h <= nCachedBlockHeight + 8; h++){

src/masternode-payments.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ class CMasternodePayments
205205

206206
bool GetBlockPayee(int nBlockHeight, CScript& payee);
207207
bool IsTransactionValid(const CTransaction& txNew, int nBlockHeight);
208-
bool IsScheduled(const CMasternode& mn, int nNotBlockHeight);
208+
bool IsScheduled(const masternode_info_t& mnInfo, int nNotBlockHeight);
209209

210210
bool CanVote(COutPoint outMasternode, int nBlockHeight);
211211

src/privatesend-client.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "consensus/validation.h"
99
#include "core_io.h"
1010
#include "init.h"
11+
#include "masternode-payments.h"
1112
#include "masternode-sync.h"
1213
#include "masternodeman.h"
1314
#include "netmessagemaker.h"
@@ -853,6 +854,12 @@ bool CPrivateSendClient::JoinExistingQueue(CAmount nBalanceNeedsAnonymized, CCon
853854

854855
if(infoMn.nProtocolVersion < MIN_PRIVATESEND_PEER_PROTO_VERSION) continue;
855856

857+
// skip next mn payments winners
858+
if (mnpayments.IsScheduled(infoMn, 0)) {
859+
LogPrintf("CPrivateSendClient::JoinExistingQueue -- skipping winner, masternode=%s\n", infoMn.vin.prevout.ToStringShort());
860+
continue;
861+
}
862+
856863
std::vector<int> vecBits;
857864
if(!CPrivateSend::GetDenominationsBits(dsq.nDenom, vecBits)) {
858865
// incompatible denom
@@ -916,11 +923,20 @@ bool CPrivateSendClient::StartNewQueue(CAmount nValueMin, CAmount nBalanceNeedsA
916923
// otherwise, try one randomly
917924
while(nTries < 10) {
918925
masternode_info_t infoMn = mnodeman.FindRandomNotInVec(vecMasternodesUsed, MIN_PRIVATESEND_PEER_PROTO_VERSION);
926+
919927
if(!infoMn.fInfoValid) {
920928
LogPrintf("CPrivateSendClient::StartNewQueue -- Can't find random masternode!\n");
921929
strAutoDenomResult = _("Can't find random Masternode.");
922930
return false;
923931
}
932+
933+
// skip next mn payments winners
934+
if (mnpayments.IsScheduled(infoMn, 0)) {
935+
LogPrintf("CPrivateSendClient::StartNewQueue -- skipping winner, masternode=%s\n", infoMn.vin.prevout.ToStringShort());
936+
nTries++;
937+
continue;
938+
}
939+
924940
vecMasternodesUsed.push_back(infoMn.vin.prevout);
925941

926942
if(infoMn.nLastDsq != 0 && infoMn.nLastDsq + nMnCountEnabled/5 > mnodeman.nDsqCount) {

0 commit comments

Comments
 (0)