fix number of blocks to wait after successful mixing tx (#1597)

This commit is contained in:
UdjinM6 2017-09-03 16:30:58 +03:00 committed by GitHub
parent 4f0618ae8a
commit 82595b1b91
3 changed files with 21 additions and 6 deletions

View File

@ -1911,7 +1911,10 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
privateSendClient.nLiquidityProvider = std::min(std::max((int)GetArg("-liquidityprovider", DEFAULT_PRIVATESEND_LIQUIDITY), 0), 100);
privateSendClient.SetMinBlockSpacing(privateSendClient.nLiquidityProvider * 15);
if(privateSendClient.nLiquidityProvider) {
// special case for liquidity providers only, normal clients should use default value
privateSendClient.SetMinBlocksToWait(privateSendClient.nLiquidityProvider * 15);
}
privateSendClient.fEnablePrivateSend = GetBoolArg("-enableprivatesend", false);
privateSendClient.fPrivateSendMultiSession = GetBoolArg("-privatesendmultisession", DEFAULT_PRIVATESEND_MULTISESSION);

View File

@ -242,7 +242,7 @@ std::string CPrivateSendClient::GetStatus()
nStatusMessageProgress += 10;
std::string strSuffix = "";
if((nCachedBlockHeight - nCachedLastSuccessBlock < nMinBlockSpacing) || !masternodeSync.IsBlockchainSynced())
if(WaitForAnotherBlock() || !masternodeSync.IsBlockchainSynced())
return strAutoDenomResult;
switch(nState) {
@ -587,6 +587,16 @@ void CPrivateSendClient::CompletedTransaction(PoolMessage nMessageID)
strLastMessage = CPrivateSend::GetMessageByID(nMessageID);
}
bool CPrivateSendClient::WaitForAnotherBlock()
{
if(!masternodeSync.IsMasternodeListSynced())
return true;
if(fPrivateSendMultiSession)
return false;
return nCachedBlockHeight - nCachedLastSuccessBlock < nMinBlocksToWait;
}
bool CPrivateSendClient::CheckAutomaticBackup()
{
@ -687,7 +697,7 @@ bool CPrivateSendClient::DoAutomaticDenominating(CConnman& connman, bool fDryRun
return false;
}
if(!fPrivateSendMultiSession && nCachedBlockHeight - nCachedLastSuccessBlock < nMinBlockSpacing) {
if(WaitForAnotherBlock()) {
LogPrintf("CPrivateSendClient::DoAutomaticDenominating -- Last successful PrivateSend action was too recent\n");
strAutoDenomResult = _("Last successful PrivateSend action was too recent.");
return false;

View File

@ -42,7 +42,7 @@ private:
std::vector<COutPoint> vecOutPointLocked;
int nCachedLastSuccessBlock;
int nMinBlockSpacing; //required blocks between mixes
int nMinBlocksToWait; // how many blocks to wait after one successful mixing tx in non-multisession mode
// Keep track of current block height
int nCachedBlockHeight;
@ -63,6 +63,8 @@ private:
return std::find(vecDenominationsSkipped.begin(), vecDenominationsSkipped.end(), nDenomValue) != vecDenominationsSkipped.end();
}
bool WaitForAnotherBlock();
// Make sure we have enough keys since last backup
bool CheckAutomaticBackup();
bool JoinExistingQueue(CAmount nBalanceNeedsAnonymized);
@ -108,7 +110,7 @@ public:
CPrivateSendClient() :
nCachedLastSuccessBlock(0),
nMinBlockSpacing(0),
nMinBlocksToWait(1),
txMyCollateral(CMutableTransaction()),
nPrivateSendRounds(DEFAULT_PRIVATESEND_ROUNDS),
nPrivateSendAmount(DEFAULT_PRIVATESEND_AMOUNT),
@ -122,7 +124,7 @@ public:
void ClearSkippedDenominations() { vecDenominationsSkipped.clear(); }
void SetMinBlockSpacing(int nMinBlockSpacingIn) { nMinBlockSpacing = nMinBlockSpacingIn; }
void SetMinBlocksToWait(int nMinBlocksToWaitIn) { nMinBlocksToWait = nMinBlocksToWaitIn; }
void ResetPool();