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;
|
if(sessionTotalValue > maxAmount*COIN) sessionTotalValue = maxAmount*COIN;
|
||||||
|
|
||||||
double fDarkcoinSubmitted = (sessionTotalValue / CENT);
|
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
|
if(pwalletMain->GetDenominatedBalance(true, true) > 0){ //get denominated unconfirmed inputs
|
||||||
LogPrintf("DoAutomaticDenominating -- Found unconfirmed denominated outputs, will wait till they confirm to continue.\n");
|
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 nValueMin = 0.01*COIN;
|
||||||
int64_t nValueIn = 0;
|
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
|
// Calculate total mixable funds
|
||||||
if (!pwalletMain->SelectCoinsDark(nValueMin, 999999*COIN, vCoins, nValueIn, -2, 10)) {
|
if (!pwalletMain->SelectCoinsDark(nValueMin, 999999*COIN, vCoins, nValueIn, -2, 10)) {
|
||||||
ui->darksendProgress->setValue(0);
|
ui->darksendProgress->setValue(0);
|
||||||
@ -270,14 +277,17 @@ void OverviewPage::updateDarksendProgress(){
|
|||||||
}
|
}
|
||||||
double nTotalValue = pwalletMain->GetTotalValue(vCoins)/CENT;
|
double nTotalValue = pwalletMain->GetTotalValue(vCoins)/CENT;
|
||||||
|
|
||||||
//Get average rounds of inputs
|
|
||||||
double a = (double)pwalletMain->GetAverageAnonymizedRounds() / (double)nDarksendRounds;
|
|
||||||
//Get the anon threshold
|
//Get the anon threshold
|
||||||
double max = nAnonymizeDarkcoinAmount*100;
|
double max = nAnonymizeDarkcoinAmount*100;
|
||||||
//If it's more than the wallet amount, limit to that.
|
//If it's more than the wallet amount, limit to that.
|
||||||
if(max > (double)nTotalValue) max = (double)nTotalValue;
|
if(max > (double)nTotalValue) max = (double)nTotalValue;
|
||||||
//denominated balance / anon threshold -- the percentage that we've completed
|
//denominated balance / anon threshold -- the percentage that we've completed
|
||||||
double b = ((double)(pwalletMain->GetDenominatedBalance()/CENT) / max);
|
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;
|
double val = a*b*100;
|
||||||
if(val < 0) val = 0;
|
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)
|
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
|
||||||
{
|
{
|
||||||
const CWalletTx* pcoin = &(*it).second;
|
const CWalletTx* pcoin = &(*it).second;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < pcoin->vout.size(); i++) {
|
for (unsigned int i = 0; i < pcoin->vout.size(); i++) {
|
||||||
|
|
||||||
COutput out = COutput(pcoin, i, pcoin->GetDepthInMainChain());
|
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;
|
const CWalletTx* pcoin = &(*it).second;
|
||||||
|
|
||||||
bool isDenom = false;
|
|
||||||
for (unsigned int i = 0; i < pcoin->vout.size(); i++)
|
for (unsigned int i = 0; i < pcoin->vout.size(); i++)
|
||||||
BOOST_FOREACH(int64_t d, darkSendDenominations)
|
{
|
||||||
if(pcoin->vout[i].nValue == d)
|
COutput out = COutput(pcoin, i, pcoin->GetDepthInMainChain());
|
||||||
isDenom = true;
|
CTxIn vin = CTxIn(out.tx->GetHash(), out.i);
|
||||||
|
|
||||||
if(onlyUnconfirmed){
|
bool unconfirmed = (!IsFinalTx(*pcoin) || (!pcoin->IsTrusted() && pcoin->GetDepthInMainChain() == 0));
|
||||||
if (!pcoin->IsTrusted()){
|
|
||||||
if(onlyDenom == isDenom){
|
if(IsSpent(out.tx->GetHash(), i)) continue;
|
||||||
nTotal += pcoin->GetAvailableCredit();
|
if(!IsMine(pcoin->vout[i])) continue;
|
||||||
}
|
if(onlyUnconfirmed != unconfirmed) continue;
|
||||||
}
|
|
||||||
} else if (pcoin->IsTrusted()) {
|
int rounds = GetInputDarksendRounds(vin);
|
||||||
if(onlyDenom == isDenom) {
|
if(onlyDenom != (rounds>=0)) continue;
|
||||||
nTotal += pcoin->GetAvailableCredit();
|
|
||||||
}
|
nTotal += pcoin->vout[i].nValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return nTotal;
|
return nTotal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user