[PrivateSend] Allow more than 3 mixing participants (#2612)
This commit is contained in:
parent
0acfbf640d
commit
5c5932eb93
@ -296,7 +296,8 @@ public:
|
||||
fAllowMultipleAddressesFromGroup = false;
|
||||
fAllowMultiplePorts = false;
|
||||
|
||||
nPoolMaxTransactions = 3;
|
||||
nPoolMinParticipants = 3;
|
||||
nPoolMaxParticipants = 5;
|
||||
nFulfilledRequestExpireTime = 60*60; // fulfilled requests expire in 1 hour
|
||||
|
||||
vSporkAddresses = {"Xgtyuk76vhuFW2iT7UAiHgNdWXCf3J34wh"};
|
||||
@ -463,7 +464,8 @@ public:
|
||||
fAllowMultipleAddressesFromGroup = false;
|
||||
fAllowMultiplePorts = false;
|
||||
|
||||
nPoolMaxTransactions = 3;
|
||||
nPoolMinParticipants = 3;
|
||||
nPoolMaxParticipants = 5;
|
||||
nFulfilledRequestExpireTime = 5*60; // fulfilled requests expire in 5 minutes
|
||||
|
||||
vSporkAddresses = {"yjPtiKh2uwk3bDutTEA2q9mCtXyiZRWn55"};
|
||||
@ -608,7 +610,8 @@ public:
|
||||
fAllowMultipleAddressesFromGroup = true;
|
||||
fAllowMultiplePorts = true;
|
||||
|
||||
nPoolMaxTransactions = 3;
|
||||
nPoolMinParticipants = 3;
|
||||
nPoolMaxParticipants = 5;
|
||||
nFulfilledRequestExpireTime = 5*60; // fulfilled requests expire in 5 minutes
|
||||
|
||||
vSporkAddresses = {"yjPtiKh2uwk3bDutTEA2q9mCtXyiZRWn55"};
|
||||
|
@ -86,7 +86,8 @@ public:
|
||||
const std::vector<SeedSpec6>& FixedSeeds() const { return vFixedSeeds; }
|
||||
const CCheckpointData& Checkpoints() const { return checkpointData; }
|
||||
const ChainTxData& TxData() const { return chainTxData; }
|
||||
int PoolMaxTransactions() const { return nPoolMaxTransactions; }
|
||||
int PoolMinParticipants() const { return nPoolMinParticipants; }
|
||||
int PoolMaxParticipants() const { return nPoolMaxParticipants; }
|
||||
int FulfilledRequestExpireTime() const { return nFulfilledRequestExpireTime; }
|
||||
const std::vector<std::string>& SporkAddresses() const { return vSporkAddresses; }
|
||||
int MinSporkKeys() const { return nMinSporkKeys; }
|
||||
@ -116,7 +117,8 @@ protected:
|
||||
bool fAllowMultiplePorts;
|
||||
CCheckpointData checkpointData;
|
||||
ChainTxData chainTxData;
|
||||
int nPoolMaxTransactions;
|
||||
int nPoolMinParticipants;
|
||||
int nPoolMaxParticipants;
|
||||
int nFulfilledRequestExpireTime;
|
||||
std::vector<std::string> vSporkAddresses;
|
||||
int nMinSporkKeys;
|
||||
|
@ -320,14 +320,14 @@ std::string CPrivateSendClientSession::GetStatus(bool fWaitForBlock)
|
||||
return _("PrivateSend request complete:") + " " + _("Your transaction was accepted into the pool!");
|
||||
} else {
|
||||
if (nStatusMessageProgress % 70 <= 40)
|
||||
return strprintf(_("Submitted following entries to masternode: %u / %d"), nEntriesCount, CPrivateSend::GetMaxPoolTransactions());
|
||||
return strprintf(_("Submitted following entries to masternode: %u"), nEntriesCount);
|
||||
else if (nStatusMessageProgress % 70 <= 50)
|
||||
strSuffix = ".";
|
||||
else if (nStatusMessageProgress % 70 <= 60)
|
||||
strSuffix = "..";
|
||||
else if (nStatusMessageProgress % 70 <= 70)
|
||||
strSuffix = "...";
|
||||
return strprintf(_("Submitted to masternode, waiting for more entries ( %u / %d ) %s"), nEntriesCount, CPrivateSend::GetMaxPoolTransactions(), strSuffix);
|
||||
return strprintf(_("Submitted to masternode, waiting for more entries ( %u ) %s"), nEntriesCount, strSuffix);
|
||||
}
|
||||
case POOL_STATE_SIGNING:
|
||||
if (nStatusMessageProgress % 70 <= 40)
|
||||
|
@ -280,6 +280,7 @@ void CPrivateSendServer::SetNull()
|
||||
{
|
||||
// MN side
|
||||
vecSessionCollaterals.clear();
|
||||
nSessionMaxParticipants = NULL;
|
||||
|
||||
CPrivateSendBaseSession::SetNull();
|
||||
CPrivateSendBaseManager::SetNull();
|
||||
@ -295,7 +296,7 @@ void CPrivateSendServer::CheckPool(CConnman& connman)
|
||||
LogPrint("privatesend", "CPrivateSendServer::CheckPool -- entries count %lu\n", GetEntriesCount());
|
||||
|
||||
// If entries are full, create finalized transaction
|
||||
if (nState == POOL_STATE_ACCEPTING_ENTRIES && GetEntriesCount() >= CPrivateSend::GetMaxPoolTransactions()) {
|
||||
if (nState == POOL_STATE_ACCEPTING_ENTRIES && GetEntriesCount() >= nSessionMaxParticipants) {
|
||||
LogPrint("privatesend", "CPrivateSendServer::CheckPool -- FINALIZE TRANSACTIONS\n");
|
||||
CreateFinalTransaction(connman);
|
||||
return;
|
||||
@ -435,10 +436,10 @@ void CPrivateSendServer::ChargeFees(CConnman& connman)
|
||||
if (vecOffendersCollaterals.empty()) return;
|
||||
|
||||
//mostly offending? Charge sometimes
|
||||
if ((int)vecOffendersCollaterals.size() >= Params().PoolMaxTransactions() - 1 && GetRandInt(100) > 33) return;
|
||||
if ((int)vecOffendersCollaterals.size() >= nSessionMaxParticipants - 1 && GetRandInt(100) > 33) return;
|
||||
|
||||
//everyone is an offender? That's not right
|
||||
if ((int)vecOffendersCollaterals.size() >= Params().PoolMaxTransactions()) return;
|
||||
if ((int)vecOffendersCollaterals.size() >= nSessionMaxParticipants) return;
|
||||
|
||||
//charge one of the offenders randomly
|
||||
std::random_shuffle(vecOffendersCollaterals.begin(), vecOffendersCollaterals.end());
|
||||
@ -593,7 +594,7 @@ bool CPrivateSendServer::AddEntry(const CPrivateSendEntry& entryNew, PoolMessage
|
||||
return false;
|
||||
}
|
||||
|
||||
if (GetEntriesCount() >= CPrivateSend::GetMaxPoolTransactions()) {
|
||||
if (GetEntriesCount() >= nSessionMaxParticipants) {
|
||||
LogPrint("privatesend", "CPrivateSendServer::AddEntry -- entries is full!\n");
|
||||
nMessageIDRet = ERR_ENTRIES_FULL;
|
||||
return false;
|
||||
@ -722,6 +723,7 @@ bool CPrivateSendServer::CreateNewSession(const CPrivateSendAccept& dsa, PoolMes
|
||||
nMessageIDRet = MSG_NOERR;
|
||||
nSessionID = GetRandInt(999999) + 1;
|
||||
nSessionDenom = dsa.nDenom;
|
||||
nSessionMaxParticipants = CPrivateSend::GetMinPoolParticipants() + GetRandInt(CPrivateSend::GetMaxPoolParticipants() - CPrivateSend::GetMinPoolParticipants() + 1);
|
||||
|
||||
SetState(POOL_STATE_QUEUE);
|
||||
nTimeLastSuccessfulStep = GetTime();
|
||||
|
@ -22,6 +22,9 @@ private:
|
||||
// to behave honestly. If they don't it takes their money.
|
||||
std::vector<CTransactionRef> vecSessionCollaterals;
|
||||
|
||||
// Maximum number of participants in a certain session, random between min and max.
|
||||
int nSessionMaxParticipants;
|
||||
|
||||
bool fUnitTest;
|
||||
|
||||
/// Add a clients entry to the pool
|
||||
@ -45,7 +48,7 @@ private:
|
||||
bool CreateNewSession(const CPrivateSendAccept& dsa, PoolMessage& nMessageIDRet, CConnman& connman);
|
||||
bool AddUserToExistingSession(const CPrivateSendAccept& dsa, PoolMessage& nMessageIDRet);
|
||||
/// Do we have enough users to take entries?
|
||||
bool IsSessionReady() { return (int)vecSessionCollaterals.size() >= CPrivateSend::GetMaxPoolTransactions(); }
|
||||
bool IsSessionReady() { return (int)vecSessionCollaterals.size() >= nSessionMaxParticipants; }
|
||||
|
||||
/// Check that all inputs are signed. (Are all inputs signed?)
|
||||
bool IsSignaturesComplete();
|
||||
|
@ -403,8 +403,9 @@ public:
|
||||
|
||||
static std::string GetMessageByID(PoolMessage nMessageID);
|
||||
|
||||
/// Get the maximum number of transactions for the pool
|
||||
static int GetMaxPoolTransactions() { return Params().PoolMaxTransactions(); }
|
||||
/// Get the minimum/maximum number of participants for the pool
|
||||
static int GetMinPoolParticipants() { return Params().PoolMinParticipants(); }
|
||||
static int GetMaxPoolParticipants() { return Params().PoolMaxParticipants(); }
|
||||
|
||||
static CAmount GetMaxPoolAmount() { return vecStandardDenominations.empty() ? 0 : PRIVATESEND_ENTRY_MAX_SIZE * vecStandardDenominations.front(); }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user