Skip next mn payments winners when selecting a MN to mix on (#1921)

This commit is contained in:
UdjinM6 2018-02-12 15:47:20 +03:00 committed by GitHub
parent 0670695fea
commit 271c249e15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 3 deletions

View File

@ -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++){

View File

@ -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);

View File

@ -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<int> 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) {