mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 20:42:59 +01:00
fix: Update conditions and unify calculations for the number of "winners" to skip when mixing (#5532)
## Issue being fixed or feature implemented `JoinExistingQueue` was tweaked for regtest/devnets in #4394 but we have "skipping winners" logic in `StartNewQueue` too. We should also use weighted count when checking "skip winners" conditions. ## What was done? Add a helper to calculate the number and use it in both methods. Adjust logic. ## How Has This Been Tested? Running a local mixing node on devnet ~- no "skipping winners" in logs anymore.~ and testnet ## Breaking Changes n/a ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone
This commit is contained in:
parent
9f7322b34a
commit
24a4ed3f8b
@ -1042,18 +1042,20 @@ CDeterministicMNCPtr CCoinJoinClientManager::GetRandomNotUsedMasternode()
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int WinnersToSkip()
|
||||||
|
{
|
||||||
|
return (Params().NetworkIDString() == CBaseChainParams::DEVNET ||
|
||||||
|
Params().NetworkIDString() == CBaseChainParams::REGTEST)
|
||||||
|
? 1 : 8;
|
||||||
|
}
|
||||||
|
|
||||||
bool CCoinJoinClientSession::JoinExistingQueue(CAmount nBalanceNeedsAnonymized, CConnman& connman)
|
bool CCoinJoinClientSession::JoinExistingQueue(CAmount nBalanceNeedsAnonymized, CConnman& connman)
|
||||||
{
|
{
|
||||||
if (!CCoinJoinClientOptions::IsEnabled()) return false;
|
if (!CCoinJoinClientOptions::IsEnabled()) return false;
|
||||||
if (coinJoinClientQueueManager == nullptr) return false;
|
if (coinJoinClientQueueManager == nullptr) return false;
|
||||||
|
|
||||||
auto mnList = deterministicMNManager->GetListAtChainTip();
|
const auto mnList = deterministicMNManager->GetListAtChainTip();
|
||||||
|
const int nWeightedMnCount = mnList.GetValidWeightedMNsCount();
|
||||||
int winners_to_skip{8};
|
|
||||||
|
|
||||||
if (Params().NetworkIDString() == CBaseChainParams::DEVNET || Params().NetworkIDString() == CBaseChainParams::REGTEST) {
|
|
||||||
winners_to_skip = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Look through the queues and see if anything matches
|
// Look through the queues and see if anything matches
|
||||||
CCoinJoinQueue dsq;
|
CCoinJoinQueue dsq;
|
||||||
@ -1066,7 +1068,7 @@ bool CCoinJoinClientSession::JoinExistingQueue(CAmount nBalanceNeedsAnonymized,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// skip next mn payments winners
|
// skip next mn payments winners
|
||||||
if (dmn->pdmnState->nLastPaidHeight + int(mnList.GetValidMNsCount()) < mnList.GetHeight() + winners_to_skip) {
|
if (dmn->pdmnState->nLastPaidHeight + nWeightedMnCount < mnList.GetHeight() + WinnersToSkip()) {
|
||||||
LogPrint(BCLog::COINJOIN, "CCoinJoinClientSession::JoinExistingQueue -- skipping winner, masternode=%s\n", dmn->proTxHash.ToString());
|
LogPrint(BCLog::COINJOIN, "CCoinJoinClientSession::JoinExistingQueue -- skipping winner, masternode=%s\n", dmn->proTxHash.ToString());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1113,8 +1115,9 @@ bool CCoinJoinClientSession::StartNewQueue(CAmount nBalanceNeedsAnonymized, CCon
|
|||||||
if (nBalanceNeedsAnonymized <= 0) return false;
|
if (nBalanceNeedsAnonymized <= 0) return false;
|
||||||
|
|
||||||
int nTries = 0;
|
int nTries = 0;
|
||||||
auto mnList = deterministicMNManager->GetListAtChainTip();
|
const auto mnList = deterministicMNManager->GetListAtChainTip();
|
||||||
int nMnCount = mnList.GetValidMNsCount();
|
const int nMnCount = mnList.GetValidMNsCount();
|
||||||
|
const int nWeightedMnCount = mnList.GetValidWeightedMNsCount();
|
||||||
|
|
||||||
// find available denominated amounts
|
// find available denominated amounts
|
||||||
std::set<CAmount> setAmounts;
|
std::set<CAmount> setAmounts;
|
||||||
@ -1138,7 +1141,7 @@ bool CCoinJoinClientSession::StartNewQueue(CAmount nBalanceNeedsAnonymized, CCon
|
|||||||
coinJoinClientManagers.at(mixingWallet.GetName())->AddUsedMasternode(dmn->collateralOutpoint);
|
coinJoinClientManagers.at(mixingWallet.GetName())->AddUsedMasternode(dmn->collateralOutpoint);
|
||||||
|
|
||||||
// skip next mn payments winners
|
// skip next mn payments winners
|
||||||
if (dmn->pdmnState->nLastPaidHeight + nMnCount < mnList.GetHeight() + 8) {
|
if (dmn->pdmnState->nLastPaidHeight + nWeightedMnCount < mnList.GetHeight() + WinnersToSkip()) {
|
||||||
LogPrint(BCLog::COINJOIN, "CCoinJoinClientSession::StartNewQueue -- skipping winner, masternode=%s\n", dmn->proTxHash.ToString());
|
LogPrint(BCLog::COINJOIN, "CCoinJoinClientSession::StartNewQueue -- skipping winner, masternode=%s\n", dmn->proTxHash.ToString());
|
||||||
nTries++;
|
nTries++;
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user