Allow up to MASTERNODE_MAX_MIXING_TXES (5) DSTXes per MN in a row (#2552)

This commit is contained in:
UdjinM6 2018-12-13 11:13:02 +03:00 committed by Alexander Block
parent 3e97b0cbdb
commit 07309f0ec3
4 changed files with 18 additions and 16 deletions

View File

@ -24,14 +24,12 @@
CMasternode::CMasternode() : CMasternode::CMasternode() :
masternode_info_t{ MASTERNODE_ENABLED, PROTOCOL_VERSION, GetAdjustedTime()}, masternode_info_t{ MASTERNODE_ENABLED, PROTOCOL_VERSION, GetAdjustedTime()}
fAllowMixingTx(true)
{} {}
CMasternode::CMasternode(CService addr, COutPoint outpoint, CPubKey pubKeyCollateralAddressNew, CPubKey pubKeyMasternodeNew, int nProtocolVersionIn) : CMasternode::CMasternode(CService addr, COutPoint outpoint, CPubKey pubKeyCollateralAddressNew, CPubKey pubKeyMasternodeNew, int nProtocolVersionIn) :
masternode_info_t{ MASTERNODE_ENABLED, nProtocolVersionIn, GetAdjustedTime(), masternode_info_t{ MASTERNODE_ENABLED, nProtocolVersionIn, GetAdjustedTime(),
outpoint, addr, pubKeyCollateralAddressNew, pubKeyMasternodeNew}, outpoint, addr, pubKeyCollateralAddressNew, pubKeyMasternodeNew}
fAllowMixingTx(true)
{} {}
CMasternode::CMasternode(const CMasternode& other) : CMasternode::CMasternode(const CMasternode& other) :
@ -42,7 +40,7 @@ CMasternode::CMasternode(const CMasternode& other) :
nBlockLastPaid(other.nBlockLastPaid), nBlockLastPaid(other.nBlockLastPaid),
nPoSeBanScore(other.nPoSeBanScore), nPoSeBanScore(other.nPoSeBanScore),
nPoSeBanHeight(other.nPoSeBanHeight), nPoSeBanHeight(other.nPoSeBanHeight),
fAllowMixingTx(other.fAllowMixingTx), nMixingTxCount(other.nMixingTxCount),
fUnitTest(other.fUnitTest) fUnitTest(other.fUnitTest)
{} {}
@ -50,14 +48,12 @@ CMasternode::CMasternode(const CMasternodeBroadcast& mnb) :
masternode_info_t{ mnb.nActiveState, mnb.nProtocolVersion, mnb.sigTime, masternode_info_t{ mnb.nActiveState, mnb.nProtocolVersion, mnb.sigTime,
mnb.outpoint, mnb.addr, mnb.pubKeyCollateralAddress, mnb.pubKeyMasternode}, mnb.outpoint, mnb.addr, mnb.pubKeyCollateralAddress, mnb.pubKeyMasternode},
lastPing(mnb.lastPing), lastPing(mnb.lastPing),
vchSig(mnb.vchSig), vchSig(mnb.vchSig)
fAllowMixingTx(true)
{} {}
CMasternode::CMasternode(const uint256 &proTxHash, const CDeterministicMNCPtr& dmn) : CMasternode::CMasternode(const uint256 &proTxHash, const CDeterministicMNCPtr& dmn) :
masternode_info_t{ MASTERNODE_ENABLED, DMN_PROTO_VERSION, GetAdjustedTime(), masternode_info_t{ MASTERNODE_ENABLED, DMN_PROTO_VERSION, GetAdjustedTime(),
dmn->collateralOutpoint, dmn->pdmnState->addr, CKeyID() /* not valid with DIP3 */, dmn->pdmnState->keyIDOwner, dmn->pdmnState->pubKeyOperator, dmn->pdmnState->keyIDVoting}, dmn->collateralOutpoint, dmn->pdmnState->addr, CKeyID() /* not valid with DIP3 */, dmn->pdmnState->keyIDOwner, dmn->pdmnState->pubKeyOperator, dmn->pdmnState->keyIDVoting}
fAllowMixingTx(true)
{ {
} }

View File

@ -24,6 +24,7 @@ static const int MASTERNODE_EXPIRATION_SECONDS = 120 * 60;
static const int MASTERNODE_NEW_START_REQUIRED_SECONDS = 180 * 60; static const int MASTERNODE_NEW_START_REQUIRED_SECONDS = 180 * 60;
static const int MASTERNODE_POSE_BAN_MAX_SCORE = 5; static const int MASTERNODE_POSE_BAN_MAX_SCORE = 5;
static const int MASTERNODE_MAX_MIXING_TXES = 5;
// //
// The Masternode Ping Class : Contains a different serialize method for sending pings from masternodes throughout the network // The Masternode Ping Class : Contains a different serialize method for sending pings from masternodes throughout the network
@ -179,7 +180,7 @@ public:
int nBlockLastPaid{}; int nBlockLastPaid{};
int nPoSeBanScore{}; int nPoSeBanScore{};
int nPoSeBanHeight{}; int nPoSeBanHeight{};
bool fAllowMixingTx{}; int nMixingTxCount{};
bool fUnitTest = false; bool fUnitTest = false;
// KEEP TRACK OF GOVERNANCE ITEMS EACH MASTERNODE HAS VOTE UPON FOR RECALCULATION // KEEP TRACK OF GOVERNANCE ITEMS EACH MASTERNODE HAS VOTE UPON FOR RECALCULATION
@ -217,7 +218,7 @@ public:
READWRITE(nProtocolVersion); READWRITE(nProtocolVersion);
READWRITE(nPoSeBanScore); READWRITE(nPoSeBanScore);
READWRITE(nPoSeBanHeight); READWRITE(nPoSeBanHeight);
READWRITE(fAllowMixingTx); READWRITE(nMixingTxCount);
READWRITE(fUnitTest); READWRITE(fUnitTest);
READWRITE(mapGovernanceObjectsVotedOn); READWRITE(mapGovernanceObjectsVotedOn);
} }
@ -275,6 +276,11 @@ public:
return false; return false;
} }
bool IsValidForMixingTxes() const
{
return nMixingTxCount <= MASTERNODE_MAX_MIXING_TXES;
}
bool IsValidNetAddr(); bool IsValidNetAddr();
static bool IsValidNetAddr(CService addrIn); static bool IsValidNetAddr(CService addrIn);
@ -308,7 +314,7 @@ public:
nBlockLastPaid = from.nBlockLastPaid; nBlockLastPaid = from.nBlockLastPaid;
nPoSeBanScore = from.nPoSeBanScore; nPoSeBanScore = from.nPoSeBanScore;
nPoSeBanHeight = from.nPoSeBanHeight; nPoSeBanHeight = from.nPoSeBanHeight;
fAllowMixingTx = from.fAllowMixingTx; nMixingTxCount = from.nMixingTxCount;
fUnitTest = from.fUnitTest; fUnitTest = from.fUnitTest;
mapGovernanceObjectsVotedOn = from.mapGovernanceObjectsVotedOn; mapGovernanceObjectsVotedOn = from.mapGovernanceObjectsVotedOn;
return *this; return *this;

View File

@ -28,7 +28,7 @@
/** Masternode manager */ /** Masternode manager */
CMasternodeMan mnodeman; CMasternodeMan mnodeman;
const std::string CMasternodeMan::SERIALIZATION_VERSION_STRING = "CMasternodeMan-Version-11"; const std::string CMasternodeMan::SERIALIZATION_VERSION_STRING = "CMasternodeMan-Version-12";
const int CMasternodeMan::LAST_PAID_SCAN_BLOCKS = 100; const int CMasternodeMan::LAST_PAID_SCAN_BLOCKS = 100;
struct CompareLastPaidBlock struct CompareLastPaidBlock
@ -136,7 +136,7 @@ bool CMasternodeMan::AllowMixing(const COutPoint &outpoint)
} }
nDsqCount++; nDsqCount++;
pmn->nLastDsq = nDsqCount; pmn->nLastDsq = nDsqCount;
pmn->fAllowMixingTx = true; pmn->nMixingTxCount = 0;
return true; return true;
} }
@ -148,7 +148,7 @@ bool CMasternodeMan::DisallowMixing(const COutPoint &outpoint)
if (!pmn) { if (!pmn) {
return false; return false;
} }
pmn->fAllowMixingTx = false; pmn->nMixingTxCount++;
return true; return true;
} }

View File

@ -2086,7 +2086,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
return false; return false;
} }
if(!mn.fAllowMixingTx) { if(!mn.IsValidForMixingTxes()) {
LogPrint("privatesend", "DSTX -- Masternode %s is sending too many transactions %s\n", dstx.masternodeOutpoint.ToStringShort(), hashTx.ToString()); LogPrint("privatesend", "DSTX -- Masternode %s is sending too many transactions %s\n", dstx.masternodeOutpoint.ToStringShort(), hashTx.ToString());
return true; return true;
// TODO: Not an error? Could it be that someone is relaying old DSTXes // TODO: Not an error? Could it be that someone is relaying old DSTXes