Skip to content

Commit 5c5932e

Browse files
PastaPastaPastaUdjinM6
authored andcommitted
[PrivateSend] Allow more than 3 mixing participants (#2612)
1 parent 0acfbf6 commit 5c5932e

6 files changed

+25
-14
lines changed

src/chainparams.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,8 @@ class CMainParams : public CChainParams {
296296
fAllowMultipleAddressesFromGroup = false;
297297
fAllowMultiplePorts = false;
298298

299-
nPoolMaxTransactions = 3;
299+
nPoolMinParticipants = 3;
300+
nPoolMaxParticipants = 5;
300301
nFulfilledRequestExpireTime = 60*60; // fulfilled requests expire in 1 hour
301302

302303
vSporkAddresses = {"Xgtyuk76vhuFW2iT7UAiHgNdWXCf3J34wh"};
@@ -463,7 +464,8 @@ class CTestNetParams : public CChainParams {
463464
fAllowMultipleAddressesFromGroup = false;
464465
fAllowMultiplePorts = false;
465466

466-
nPoolMaxTransactions = 3;
467+
nPoolMinParticipants = 3;
468+
nPoolMaxParticipants = 5;
467469
nFulfilledRequestExpireTime = 5*60; // fulfilled requests expire in 5 minutes
468470

469471
vSporkAddresses = {"yjPtiKh2uwk3bDutTEA2q9mCtXyiZRWn55"};
@@ -608,7 +610,8 @@ class CDevNetParams : public CChainParams {
608610
fAllowMultipleAddressesFromGroup = true;
609611
fAllowMultiplePorts = true;
610612

611-
nPoolMaxTransactions = 3;
613+
nPoolMinParticipants = 3;
614+
nPoolMaxParticipants = 5;
612615
nFulfilledRequestExpireTime = 5*60; // fulfilled requests expire in 5 minutes
613616

614617
vSporkAddresses = {"yjPtiKh2uwk3bDutTEA2q9mCtXyiZRWn55"};

src/chainparams.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ class CChainParams
8686
const std::vector<SeedSpec6>& FixedSeeds() const { return vFixedSeeds; }
8787
const CCheckpointData& Checkpoints() const { return checkpointData; }
8888
const ChainTxData& TxData() const { return chainTxData; }
89-
int PoolMaxTransactions() const { return nPoolMaxTransactions; }
89+
int PoolMinParticipants() const { return nPoolMinParticipants; }
90+
int PoolMaxParticipants() const { return nPoolMaxParticipants; }
9091
int FulfilledRequestExpireTime() const { return nFulfilledRequestExpireTime; }
9192
const std::vector<std::string>& SporkAddresses() const { return vSporkAddresses; }
9293
int MinSporkKeys() const { return nMinSporkKeys; }
@@ -116,7 +117,8 @@ class CChainParams
116117
bool fAllowMultiplePorts;
117118
CCheckpointData checkpointData;
118119
ChainTxData chainTxData;
119-
int nPoolMaxTransactions;
120+
int nPoolMinParticipants;
121+
int nPoolMaxParticipants;
120122
int nFulfilledRequestExpireTime;
121123
std::vector<std::string> vSporkAddresses;
122124
int nMinSporkKeys;

src/privatesend-client.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -320,14 +320,14 @@ std::string CPrivateSendClientSession::GetStatus(bool fWaitForBlock)
320320
return _("PrivateSend request complete:") + " " + _("Your transaction was accepted into the pool!");
321321
} else {
322322
if (nStatusMessageProgress % 70 <= 40)
323-
return strprintf(_("Submitted following entries to masternode: %u / %d"), nEntriesCount, CPrivateSend::GetMaxPoolTransactions());
323+
return strprintf(_("Submitted following entries to masternode: %u"), nEntriesCount);
324324
else if (nStatusMessageProgress % 70 <= 50)
325325
strSuffix = ".";
326326
else if (nStatusMessageProgress % 70 <= 60)
327327
strSuffix = "..";
328328
else if (nStatusMessageProgress % 70 <= 70)
329329
strSuffix = "...";
330-
return strprintf(_("Submitted to masternode, waiting for more entries ( %u / %d ) %s"), nEntriesCount, CPrivateSend::GetMaxPoolTransactions(), strSuffix);
330+
return strprintf(_("Submitted to masternode, waiting for more entries ( %u ) %s"), nEntriesCount, strSuffix);
331331
}
332332
case POOL_STATE_SIGNING:
333333
if (nStatusMessageProgress % 70 <= 40)

src/privatesend-server.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ void CPrivateSendServer::SetNull()
280280
{
281281
// MN side
282282
vecSessionCollaterals.clear();
283+
nSessionMaxParticipants = NULL;
283284

284285
CPrivateSendBaseSession::SetNull();
285286
CPrivateSendBaseManager::SetNull();
@@ -295,7 +296,7 @@ void CPrivateSendServer::CheckPool(CConnman& connman)
295296
LogPrint("privatesend", "CPrivateSendServer::CheckPool -- entries count %lu\n", GetEntriesCount());
296297

297298
// If entries are full, create finalized transaction
298-
if (nState == POOL_STATE_ACCEPTING_ENTRIES && GetEntriesCount() >= CPrivateSend::GetMaxPoolTransactions()) {
299+
if (nState == POOL_STATE_ACCEPTING_ENTRIES && GetEntriesCount() >= nSessionMaxParticipants) {
299300
LogPrint("privatesend", "CPrivateSendServer::CheckPool -- FINALIZE TRANSACTIONS\n");
300301
CreateFinalTransaction(connman);
301302
return;
@@ -435,10 +436,10 @@ void CPrivateSendServer::ChargeFees(CConnman& connman)
435436
if (vecOffendersCollaterals.empty()) return;
436437

437438
//mostly offending? Charge sometimes
438-
if ((int)vecOffendersCollaterals.size() >= Params().PoolMaxTransactions() - 1 && GetRandInt(100) > 33) return;
439+
if ((int)vecOffendersCollaterals.size() >= nSessionMaxParticipants - 1 && GetRandInt(100) > 33) return;
439440

440441
//everyone is an offender? That's not right
441-
if ((int)vecOffendersCollaterals.size() >= Params().PoolMaxTransactions()) return;
442+
if ((int)vecOffendersCollaterals.size() >= nSessionMaxParticipants) return;
442443

443444
//charge one of the offenders randomly
444445
std::random_shuffle(vecOffendersCollaterals.begin(), vecOffendersCollaterals.end());
@@ -593,7 +594,7 @@ bool CPrivateSendServer::AddEntry(const CPrivateSendEntry& entryNew, PoolMessage
593594
return false;
594595
}
595596

596-
if (GetEntriesCount() >= CPrivateSend::GetMaxPoolTransactions()) {
597+
if (GetEntriesCount() >= nSessionMaxParticipants) {
597598
LogPrint("privatesend", "CPrivateSendServer::AddEntry -- entries is full!\n");
598599
nMessageIDRet = ERR_ENTRIES_FULL;
599600
return false;
@@ -722,6 +723,7 @@ bool CPrivateSendServer::CreateNewSession(const CPrivateSendAccept& dsa, PoolMes
722723
nMessageIDRet = MSG_NOERR;
723724
nSessionID = GetRandInt(999999) + 1;
724725
nSessionDenom = dsa.nDenom;
726+
nSessionMaxParticipants = CPrivateSend::GetMinPoolParticipants() + GetRandInt(CPrivateSend::GetMaxPoolParticipants() - CPrivateSend::GetMinPoolParticipants() + 1);
725727

726728
SetState(POOL_STATE_QUEUE);
727729
nTimeLastSuccessfulStep = GetTime();

src/privatesend-server.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ class CPrivateSendServer : public CPrivateSendBaseSession, public CPrivateSendBa
2222
// to behave honestly. If they don't it takes their money.
2323
std::vector<CTransactionRef> vecSessionCollaterals;
2424

25+
// Maximum number of participants in a certain session, random between min and max.
26+
int nSessionMaxParticipants;
27+
2528
bool fUnitTest;
2629

2730
/// Add a clients entry to the pool
@@ -45,7 +48,7 @@ class CPrivateSendServer : public CPrivateSendBaseSession, public CPrivateSendBa
4548
bool CreateNewSession(const CPrivateSendAccept& dsa, PoolMessage& nMessageIDRet, CConnman& connman);
4649
bool AddUserToExistingSession(const CPrivateSendAccept& dsa, PoolMessage& nMessageIDRet);
4750
/// Do we have enough users to take entries?
48-
bool IsSessionReady() { return (int)vecSessionCollaterals.size() >= CPrivateSend::GetMaxPoolTransactions(); }
51+
bool IsSessionReady() { return (int)vecSessionCollaterals.size() >= nSessionMaxParticipants; }
4952

5053
/// Check that all inputs are signed. (Are all inputs signed?)
5154
bool IsSignaturesComplete();

src/privatesend.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,9 @@ class CPrivateSend
403403

404404
static std::string GetMessageByID(PoolMessage nMessageID);
405405

406-
/// Get the maximum number of transactions for the pool
407-
static int GetMaxPoolTransactions() { return Params().PoolMaxTransactions(); }
406+
/// Get the minimum/maximum number of participants for the pool
407+
static int GetMinPoolParticipants() { return Params().PoolMinParticipants(); }
408+
static int GetMaxPoolParticipants() { return Params().PoolMaxParticipants(); }
408409

409410
static CAmount GetMaxPoolAmount() { return vecStandardDenominations.empty() ? 0 : PRIVATESEND_ENTRY_MAX_SIZE * vecStandardDenominations.front(); }
410411

0 commit comments

Comments
 (0)