mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 13:03:17 +01:00
fix division by 0 in ds progress calculation
This commit is contained in:
parent
77bade91be
commit
aec4020af0
@ -287,13 +287,22 @@ void OverviewPage::updateDarksendProgress()
|
|||||||
|
|
||||||
// calculate parts of the progress, each of them shouldn't be higher than 1:
|
// calculate parts of the progress, each of them shouldn't be higher than 1:
|
||||||
// mixing progress of denominated balance
|
// mixing progress of denominated balance
|
||||||
float denomPart = (float)pwalletMain->GetNormalizedAnonymizedBalance() / pwalletMain->GetDenominatedBalance();
|
int64_t denominatedBalance = pwalletMain->GetDenominatedBalance();
|
||||||
denomPart = denomPart > 1 ? 1 : denomPart;
|
float denomPart = 0;
|
||||||
|
if(denominatedBalance > 0)
|
||||||
|
{
|
||||||
|
denomPart = (float)pwalletMain->GetNormalizedAnonymizedBalance() / pwalletMain->GetDenominatedBalance();
|
||||||
|
denomPart = denomPart > 1 ? 1 : denomPart;
|
||||||
|
}
|
||||||
|
|
||||||
// % of fully anonymized balance
|
// % of fully anonymized balance
|
||||||
float anonPart = (float)pwalletMain->GetAnonymizedBalance() / nMaxToAnonymize;
|
float anonPart = 0;
|
||||||
// if anonPart is > 1 then we are done, make denomPart equal 1 too
|
if(nMaxToAnonymize > 0)
|
||||||
anonPart = anonPart > 1 ? (denomPart = 1, 1) : anonPart;
|
{
|
||||||
|
anonPart = (float)pwalletMain->GetAnonymizedBalance() / nMaxToAnonymize;
|
||||||
|
// if anonPart is > 1 then we are done, make denomPart equal 1 too
|
||||||
|
anonPart = anonPart > 1 ? (denomPart = 1, 1) : anonPart;
|
||||||
|
}
|
||||||
|
|
||||||
// apply some weights to them (sum should be <=100) and calculate the whole progress
|
// apply some weights to them (sum should be <=100) and calculate the whole progress
|
||||||
int progress = 80 * denomPart + 20 * anonPart;
|
int progress = 80 * denomPart + 20 * anonPart;
|
||||||
|
Loading…
Reference in New Issue
Block a user