Fixed progress bar / Improve GetDenominatedBalance
- Fixed a few issues when calculating progress including some variables that should be limited to 1 (a and b). GetDenominatedBalance also seemed to be giving bad results so I rewrote it to be cleaner, not sure if that was a part of the problem. - Progress bar is only recalculated when all inputs in wallet have been confirmed (will stop the progress from jumping around)
This commit is contained in:
parent
8ab351a594
commit
6df70d30b1
@ -1528,7 +1528,7 @@ bool CDarkSendPool::DoAutomaticDenominating(bool fDryRun, bool ready)
|
||||
if(sessionTotalValue > maxAmount*COIN) sessionTotalValue = maxAmount*COIN;
|
||||
|
||||
double fDarkcoinSubmitted = (sessionTotalValue / CENT);
|
||||
LogPrintf("Submiting Darksend for %f DRK CENT\n", fDarkcoinSubmitted);
|
||||
LogPrintf("Submitting Darksend for %f DRK CENT\n", fDarkcoinSubmitted);
|
||||
|
||||
if(pwalletMain->GetDenominatedBalance(true, true) > 0){ //get denominated unconfirmed inputs
|
||||
LogPrintf("DoAutomaticDenominating -- Found unconfirmed denominated outputs, will wait till they confirm to continue.\n");
|
||||
|
@ -261,6 +261,13 @@ void OverviewPage::updateDarksendProgress(){
|
||||
int64_t nValueMin = 0.01*COIN;
|
||||
int64_t nValueIn = 0;
|
||||
|
||||
if(pwalletMain->GetDenominatedBalance(true, true) > 0){ //get denominated unconfirmed inputs
|
||||
QString s("Found unconfirmed denominated outputs, will wait till they confirm to recalculate.");
|
||||
ui->darksendProgress->setToolTip(s);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Calculate total mixable funds
|
||||
if (!pwalletMain->SelectCoinsDark(nValueMin, 999999*COIN, vCoins, nValueIn, -2, 10)) {
|
||||
ui->darksendProgress->setValue(0);
|
||||
@ -270,14 +277,17 @@ void OverviewPage::updateDarksendProgress(){
|
||||
}
|
||||
double nTotalValue = pwalletMain->GetTotalValue(vCoins)/CENT;
|
||||
|
||||
//Get average rounds of inputs
|
||||
double a = (double)pwalletMain->GetAverageAnonymizedRounds() / (double)nDarksendRounds;
|
||||
//Get the anon threshold
|
||||
double max = nAnonymizeDarkcoinAmount*100;
|
||||
//If it's more than the wallet amount, limit to that.
|
||||
if(max > (double)nTotalValue) max = (double)nTotalValue;
|
||||
//denominated balance / anon threshold -- the percentage that we've completed
|
||||
double b = ((double)(pwalletMain->GetDenominatedBalance()/CENT) / max);
|
||||
if(b > 1) b = 1;
|
||||
|
||||
//Get average rounds of inputs
|
||||
double a = (double)pwalletMain->GetAverageAnonymizedRounds() / (double)nDarksendRounds;
|
||||
if(a > 1) a = 1;
|
||||
|
||||
double val = a*b*100;
|
||||
if(val < 0) val = 0;
|
||||
|
@ -1068,6 +1068,7 @@ double CWallet::GetAverageAnonymizedRounds() const
|
||||
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
|
||||
{
|
||||
const CWalletTx* pcoin = &(*it).second;
|
||||
|
||||
for (unsigned int i = 0; i < pcoin->vout.size(); i++) {
|
||||
|
||||
COutput out = COutput(pcoin, i, pcoin->GetDepthInMainChain());
|
||||
@ -1096,26 +1097,27 @@ int64_t CWallet::GetDenominatedBalance(bool onlyDenom, bool onlyUnconfirmed) con
|
||||
{
|
||||
const CWalletTx* pcoin = &(*it).second;
|
||||
|
||||
bool isDenom = false;
|
||||
for (unsigned int i = 0; i < pcoin->vout.size(); i++)
|
||||
BOOST_FOREACH(int64_t d, darkSendDenominations)
|
||||
if(pcoin->vout[i].nValue == d)
|
||||
isDenom = true;
|
||||
{
|
||||
COutput out = COutput(pcoin, i, pcoin->GetDepthInMainChain());
|
||||
CTxIn vin = CTxIn(out.tx->GetHash(), out.i);
|
||||
|
||||
if(onlyUnconfirmed){
|
||||
if (!pcoin->IsTrusted()){
|
||||
if(onlyDenom == isDenom){
|
||||
nTotal += pcoin->GetAvailableCredit();
|
||||
}
|
||||
}
|
||||
} else if (pcoin->IsTrusted()) {
|
||||
if(onlyDenom == isDenom) {
|
||||
nTotal += pcoin->GetAvailableCredit();
|
||||
}
|
||||
bool unconfirmed = (!IsFinalTx(*pcoin) || (!pcoin->IsTrusted() && pcoin->GetDepthInMainChain() == 0));
|
||||
|
||||
if(IsSpent(out.tx->GetHash(), i)) continue;
|
||||
if(!IsMine(pcoin->vout[i])) continue;
|
||||
if(onlyUnconfirmed != unconfirmed) continue;
|
||||
|
||||
int rounds = GetInputDarksendRounds(vin);
|
||||
if(onlyDenom != (rounds>=0)) continue;
|
||||
|
||||
nTotal += pcoin->vout[i].nValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return nTotal;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user