Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split PS into Manager and Session and allow running multiple mixing sessions in parallel (on client side) #2203

Merged
merged 10 commits into from
Sep 4, 2018
6 changes: 5 additions & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageGroup(_("PrivateSend options:"));
strUsage += HelpMessageOpt("-enableprivatesend=<n>", strprintf(_("Enable use of automated PrivateSend for funds stored in this wallet (0-1, default: %u)"), 0));
strUsage += HelpMessageOpt("-privatesendmultisession=<n>", strprintf(_("Enable multiple PrivateSend mixing sessions per block, experimental (0-1, default: %u)"), DEFAULT_PRIVATESEND_MULTISESSION));
strUsage += HelpMessageOpt("-privatesendsessions=<n>", strprintf(_("Use N separate masternodes in parallel to mix funds (%u-%u, default: %u)"), MIN_PRIVATESEND_SESSIONS, MAX_PRIVATESEND_SESSIONS, DEFAULT_PRIVATESEND_SESSIONS));
strUsage += HelpMessageOpt("-privatesendrounds=<n>", strprintf(_("Use N separate masternodes for each denominated input to mix funds (%u-%u, default: %u)"), MIN_PRIVATESEND_ROUNDS, MAX_PRIVATESEND_ROUNDS, DEFAULT_PRIVATESEND_ROUNDS));
strUsage += HelpMessageOpt("-privatesendamount=<n>", strprintf(_("Keep N DASH anonymized (%u-%u, default: %u)"), MIN_PRIVATESEND_AMOUNT, MAX_PRIVATESEND_AMOUNT, DEFAULT_PRIVATESEND_AMOUNT));
strUsage += HelpMessageOpt("-liquidityprovider=<n>", strprintf(_("Provide liquidity to PrivateSend by infrequently mixing coins on a continual basis (%u-%u, default: %u, 1=very frequent, high fees, %u=very infrequent, low fees)"),
Expand Down Expand Up @@ -907,6 +908,8 @@ void InitParameterInteraction()
if (nLiqProvTmp > 0) {
ForceSetArg("-enableprivatesend", "1");
LogPrintf("%s: parameter interaction: -liquidityprovider=%d -> setting -enableprivatesend=1\n", __func__, nLiqProvTmp);
ForceSetArg("-privatesendsessions", itostr(MIN_PRIVATESEND_SESSIONS));
LogPrintf("%s: parameter interaction: -liquidityprovider=%d -> setting -privatesendsessions=%d\n", __func__, nLiqProvTmp, itostr(std::numeric_limits<int>::max()));
ForceSetArg("-privatesendrounds", itostr(std::numeric_limits<int>::max()));
LogPrintf("%s: parameter interaction: -liquidityprovider=%d -> setting -privatesendrounds=%d\n", __func__, nLiqProvTmp, itostr(std::numeric_limits<int>::max()));
ForceSetArg("-privatesendamount", itostr(MAX_PRIVATESEND_AMOUNT));
Expand Down Expand Up @@ -1867,6 +1870,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)

privateSendClient.fEnablePrivateSend = GetBoolArg("-enableprivatesend", false);
privateSendClient.fPrivateSendMultiSession = GetBoolArg("-privatesendmultisession", DEFAULT_PRIVATESEND_MULTISESSION);
privateSendClient.nPrivateSendSessions = std::min(std::max((int)GetArg("-privatesendsessions", DEFAULT_PRIVATESEND_SESSIONS), MIN_PRIVATESEND_SESSIONS), MAX_PRIVATESEND_SESSIONS);
privateSendClient.nPrivateSendRounds = std::min(std::max((int)GetArg("-privatesendrounds", DEFAULT_PRIVATESEND_ROUNDS), MIN_PRIVATESEND_ROUNDS), nMaxRounds);
privateSendClient.nPrivateSendAmount = std::min(std::max((int)GetArg("-privatesendamount", DEFAULT_PRIVATESEND_AMOUNT), MIN_PRIVATESEND_AMOUNT), MAX_PRIVATESEND_AMOUNT);
#endif // ENABLE_WALLET
Expand Down Expand Up @@ -1959,7 +1963,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
scheduler.scheduleEvery(boost::bind(&CPrivateSendServer::DoMaintenance, boost::ref(privateSendServer), boost::ref(*g_connman)), 1);
#ifdef ENABLE_WALLET
else
scheduler.scheduleEvery(boost::bind(&CPrivateSendClient::DoMaintenance, boost::ref(privateSendClient), boost::ref(*g_connman)), 1);
scheduler.scheduleEvery(boost::bind(&CPrivateSendClientManager::DoMaintenance, boost::ref(privateSendClient), boost::ref(*g_connman)), 1);
#endif // ENABLE_WALLET
}

Expand Down
19 changes: 15 additions & 4 deletions src/masternodeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -718,11 +718,22 @@ void CMasternodeMan::ProcessMasternodeConnections(CConnman& connman)
//we don't care about this for regtest
if(Params().NetworkIDString() == CBaseChainParams::REGTEST) return;

connman.ForEachNode(CConnman::AllNodes, [](CNode* pnode) {
std::vector<masternode_info_t> vecMnInfo; // will be empty when no wallet
#ifdef ENABLE_WALLET
if(pnode->fMasternode && !privateSendClient.IsMixingMasternode(pnode)) {
#else
if(pnode->fMasternode) {
privateSendClient.GetMixingMasternodesInfo(vecMnInfo);
#endif // ENABLE_WALLET

connman.ForEachNode(CConnman::AllNodes, [&vecMnInfo](CNode* pnode) {
if (pnode->fMasternode) {
#ifdef ENABLE_WALLET
bool fFound = false;
for (const auto& mnInfo : vecMnInfo) {
if (pnode->addr == mnInfo.addr) {
fFound = true;
break;
}
}
if (fFound) return; // do NOT disconnect mixing masternodes
#endif // ENABLE_WALLET
LogPrintf("Closing Masternode connection: peer=%d, addr=%s\n", pnode->id, pnode->addr.ToString());
pnode->fDisconnect = true;
Expand Down
2 changes: 1 addition & 1 deletion src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static const int MAX_OUTBOUND_CONNECTIONS = 8;
/** Maximum number of addnode outgoing nodes */
static const int MAX_ADDNODE_CONNECTIONS = 8;
/** Maximum number if outgoing masternodes */
static const int MAX_OUTBOUND_MASTERNODE_CONNECTIONS = 20;
static const int MAX_OUTBOUND_MASTERNODE_CONNECTIONS = 30;
/** -listen default */
static const bool DEFAULT_LISTEN = true;
/** -upnp default */
Expand Down
Loading