(Yet) another attempt to get progress displayed right
This commit is contained in:
parent
10ad24226c
commit
a4520af056
@ -355,32 +355,30 @@ void OverviewPage::updateDarksendProgress()
|
||||
}
|
||||
ui->labelAmountRounds->setText(strAmountAndRounds);
|
||||
|
||||
// calculate parts of the progress, each of them shouldn't be higher than 1:
|
||||
// mixing progress of denominated balance
|
||||
int64_t denominatedBalance = pwalletMain->GetDenominatedBalance();
|
||||
// calculate parts of the progress, each of them shouldn't be higher than 1
|
||||
// progress of denominating
|
||||
float denomPart = 0;
|
||||
if(denominatedBalance > 0)
|
||||
{
|
||||
denomPart = (float)pwalletMain->GetNormalizedAnonymizedBalance() / denominatedBalance;
|
||||
denomPart = denomPart > 1 ? 1 : denomPart;
|
||||
}
|
||||
|
||||
// % of fully anonymized balance
|
||||
// mixing progress of denominated balance
|
||||
float anonPart = 0;
|
||||
if(nMaxToAnonymize > 0)
|
||||
{
|
||||
anonPart = (float)pwalletMain->GetAnonymizedBalance() / nMaxToAnonymize;
|
||||
|
||||
int64_t denominatedBalance = pwalletMain->GetDenominatedBalance() + nDenominatedUnconfirmedBalance;
|
||||
denomPart = (float)denominatedBalance / nMaxToAnonymize;
|
||||
denomPart = denomPart > 1 ? 1 : denomPart;
|
||||
|
||||
anonPart = (float)pwalletMain->GetNormalizedAnonymizedBalance() / 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
|
||||
int progress = 80 * denomPart + 20 * anonPart;
|
||||
denomPart = ceilf((denomPart * 20) * 100) / 100;
|
||||
anonPart = ceilf((anonPart * 80) * 100) / 100;
|
||||
float progress = denomPart + anonPart;
|
||||
if(progress >= 100) progress = 100;
|
||||
|
||||
ui->darksendProgress->setValue(progress);
|
||||
|
||||
QString strToolPip = tr("Progress: %1% (inputs have an average of %2 of %n rounds)", "", nDarksendRounds).arg(progress).arg(pwalletMain->GetAverageAnonymizedRounds());
|
||||
QString strToolPip = tr("Progress: %1% (%2% + %3%; denominated inputs have %4 of %n rounds on average)", "", nDarksendRounds)
|
||||
.arg(progress).arg(denomPart).arg(anonPart).arg(pwalletMain->GetAverageAnonymizedRounds());
|
||||
ui->darksendProgress->setToolTip(strToolPip);
|
||||
}
|
||||
|
||||
|
@ -1240,6 +1240,8 @@ CAmount CWallet::GetAnonymizedBalance() const
|
||||
return nTotal;
|
||||
}
|
||||
|
||||
// Note: calculated including unconfirmed,
|
||||
// that's ok as long as we use it for informational purposes only
|
||||
double CWallet::GetAverageAnonymizedRounds() const
|
||||
{
|
||||
double fTotal = 0;
|
||||
@ -1251,8 +1253,6 @@ double CWallet::GetAverageAnonymizedRounds() const
|
||||
{
|
||||
const CWalletTx* pcoin = &(*it).second;
|
||||
|
||||
if (pcoin->IsTrusted())
|
||||
{
|
||||
uint256 hash = (*it).first;
|
||||
|
||||
for (unsigned int i = 0; i < pcoin->vout.size(); i++) {
|
||||
@ -1267,13 +1267,14 @@ double CWallet::GetAverageAnonymizedRounds() const
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(fCount == 0) return 0;
|
||||
|
||||
return fTotal/fCount;
|
||||
}
|
||||
|
||||
// Note: calculated including unconfirmed,
|
||||
// that's ok as long as we use it for informational purposes only
|
||||
CAmount CWallet::GetNormalizedAnonymizedBalance() const
|
||||
{
|
||||
CAmount nTotal = 0;
|
||||
@ -1284,8 +1285,6 @@ CAmount CWallet::GetNormalizedAnonymizedBalance() const
|
||||
{
|
||||
const CWalletTx* pcoin = &(*it).second;
|
||||
|
||||
if (pcoin->IsTrusted())
|
||||
{
|
||||
uint256 hash = (*it).first;
|
||||
|
||||
for (unsigned int i = 0; i < pcoin->vout.size(); i++) {
|
||||
@ -1299,12 +1298,11 @@ CAmount CWallet::GetNormalizedAnonymizedBalance() const
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nTotal;
|
||||
}
|
||||
|
||||
CAmount CWallet::GetDenominatedBalance(bool onlyDenom, bool onlyUnconfirmed, bool includeAlreadyAnonymized) const
|
||||
CAmount CWallet::GetDenominatedBalance(bool denom, bool unconfirmed, bool includeAlreadyAnonymized) const
|
||||
{
|
||||
CAmount nTotal = 0;
|
||||
{
|
||||
@ -1318,15 +1316,15 @@ CAmount CWallet::GetDenominatedBalance(bool onlyDenom, bool onlyUnconfirmed, boo
|
||||
// skip conflicted
|
||||
if(nDepth < 0) continue;
|
||||
|
||||
bool unconfirmed = (!IsFinalTx(*pcoin) || (!pcoin->IsTrusted() && nDepth == 0));
|
||||
if(onlyUnconfirmed != unconfirmed) continue;
|
||||
bool isUnconfirmed = (!IsFinalTx(*pcoin) || (!pcoin->IsTrusted() && nDepth == 0));
|
||||
if(unconfirmed != isUnconfirmed) continue;
|
||||
uint256 hash = (*it).first;
|
||||
|
||||
for (unsigned int i = 0; i < pcoin->vout.size(); i++)
|
||||
{
|
||||
if(IsSpent(hash, i)) continue;
|
||||
if(!IsMine(pcoin->vout[i])) continue;
|
||||
if(onlyDenom != IsDenominatedAmount(pcoin->vout[i].nValue)) continue;
|
||||
if(denom != IsDenominatedAmount(pcoin->vout[i].nValue)) continue;
|
||||
|
||||
CTxIn vin = CTxIn(hash, i);
|
||||
int rounds = GetInputDarksendRounds(vin);
|
||||
|
@ -314,7 +314,7 @@ public:
|
||||
CAmount GetAnonymizedBalance() const;
|
||||
double GetAverageAnonymizedRounds() const;
|
||||
CAmount GetNormalizedAnonymizedBalance() const;
|
||||
CAmount GetDenominatedBalance(bool onlyDenom=true, bool onlyUnconfirmed=false, bool includeAlreadyAnonymized = true) const;
|
||||
CAmount GetDenominatedBalance(bool denom=true, bool unconfirmed=false, bool includeAlreadyAnonymized = true) const;
|
||||
CAmount GetWatchOnlyBalance() const;
|
||||
CAmount GetUnconfirmedWatchOnlyBalance() const;
|
||||
CAmount GetImmatureWatchOnlyBalance() const;
|
||||
|
Loading…
Reference in New Issue
Block a user