various improvements

This commit is contained in:
Evan Duffield 2014-08-04 11:53:52 -07:00
parent c10eb442c2
commit 1ab5aec5e6
12 changed files with 117 additions and 46 deletions

View File

@ -2829,11 +2829,13 @@ bool ProcessBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, CDiskBl
mapOrphanBlocksByPrev.erase(hashPrev);
}
//might need to reset pool
printf("ProcessBlock: ACCEPTED\n");
darkSendPool.CheckTimeout();
printf("Darksend NewBlock\n");
darkSendPool.NewBlock();
printf("ProcessBlock: ACCEPTED\n");
if (pfrom && !CSyncCheckpoint::strMasterPrivKey.empty() &&
(int)GetArg("-checkpointdepth", -1) >= 0)
@ -5289,10 +5291,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
printf("%d\n", scriptPubKeyIn[0]);
// start masternode payments
bool bMasterNodePayment = false;
// fees to foundation
@ -6808,10 +6808,11 @@ bool CDarkSendPool::DoConcessusVote(int64 nBlockHeight)
void CDarkSendPool::NewBlock()
{
if(fDisableDarksend) return;
if(fDebug) printf("CDarkSendPool::NewBlock \n");
if(IsInitialBlockDownload()) return;
if(fDebug) printf("CDarkSendPool::NewBlock \n");
printf("CDarkSendPool::NewBlock - 2\n");
{
LOCK2(cs_main, mempool.cs);
@ -6828,10 +6829,14 @@ void CDarkSendPool::NewBlock()
}
}
printf("CDarkSendPool::NewBlock - 3\n");
//send votes for next block and one after that
DoConcessusVote(pindexBest->nHeight + 2);
DoConcessusVote(pindexBest->nHeight + 3);
}
if(fDisableDarksend) return;
if(!fMasterNode){
//denominate all non-denominated inputs every 25 minutes.
@ -7065,7 +7070,6 @@ bool CDarkSendPool::SplitUpMoney(bool justCollateral)
nTotalOut += (a) + (a/5);
}
vecSend.push_back(make_pair(scriptChange, DARKSEND_COLLATERAL*5));
vecSend.push_back(make_pair(scriptChange, DARKSEND_FEE*5));
nTotalOut += (DARKSEND_COLLATERAL*5)+(DARKSEND_FEE*5);
}
@ -7073,10 +7077,10 @@ bool CDarkSendPool::SplitUpMoney(bool justCollateral)
printf(" auto2-- nTotalOut %"PRI64d"\n", nTotalOut);
if(!justCollateral){
if(nTotalOut <= 1.1*COIN || vecSend.size() < 4)
if(nTotalOut <= 1.1*COIN || vecSend.size() < 3)
return false;
} else {
if(nTotalOut <= 0.1*COIN || vecSend.size() < 2)
if(nTotalOut <= 0.1*COIN || vecSend.size() < 1)
return false;
}

View File

@ -103,7 +103,7 @@
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Balance:</string>
<string>Total Balance:</string>
</property>
</widget>
</item>
@ -129,14 +129,14 @@
</property>
</widget>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Unconfirmed:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<widget class="QLabel" name="labelUnconfirmed">
<property name="font">
<font>
@ -158,14 +158,27 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelImmatureText">
<item row="1" column="0">
<widget class="QLabel" name="labelAnonymizedText">
<property name="text">
<string>Immature:</string>
<string>Anonymized</string>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="1" column="1">
<widget class="QLabel" name="labelAnonymized">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>0 DRK</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="labelImmature">
<property name="font">
<font>
@ -184,6 +197,13 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="labelImmatureText">
<property name="text">
<string>Immature:</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>883</width>
<height>401</height>
<width>920</width>
<height>410</height>
</rect>
</property>
<property name="windowTitle">
@ -625,8 +625,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>863</width>
<height>153</height>
<width>900</width>
<height>162</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
@ -732,23 +732,23 @@
<widget class="QComboBox" name="inputType">
<property name="minimumSize">
<size>
<width>155</width>
<width>175</width>
<height>0</height>
</size>
</property>
<item>
<property name="text">
<string>Only DS+ Inputs</string>
<string>Use Anonymous Funds</string>
</property>
</item>
<item>
<property name="text">
<string>Only Non DS+ Inputs</string>
<string>Use Non-Anonymous Funds</string>
</property>
</item>
<item>
<property name="text">
<string>All Inputs</string>
<string>No Preference</string>
</property>
</item>
</widget>

View File

@ -131,15 +131,17 @@ OverviewPage::~OverviewPage()
delete ui;
}
void OverviewPage::setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance)
void OverviewPage::setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance, qint64 anonymizedBalance)
{
int unit = walletModel->getOptionsModel()->getDisplayUnit();
currentBalance = balance;
currentUnconfirmedBalance = unconfirmedBalance;
currentImmatureBalance = immatureBalance;
currentAnonymizedBalance = anonymizedBalance;
ui->labelBalance->setText(BitcoinUnits::formatWithUnit(unit, balance));
ui->labelUnconfirmed->setText(BitcoinUnits::formatWithUnit(unit, unconfirmedBalance));
ui->labelImmature->setText(BitcoinUnits::formatWithUnit(unit, immatureBalance));
ui->labelAnonymized->setText(BitcoinUnits::formatWithUnit(unit, anonymizedBalance));
// only show immature (newly mined) balance if it's non-zero, so as not to complicate things
// for the non-mining users
@ -176,8 +178,8 @@ void OverviewPage::setWalletModel(WalletModel *model)
ui->listTransactions->setModelColumn(TransactionTableModel::ToAddress);
// Keep up to date with wallet
setBalance(model->getBalance(), model->getUnconfirmedBalance(), model->getImmatureBalance());
connect(model, SIGNAL(balanceChanged(qint64, qint64, qint64)), this, SLOT(setBalance(qint64, qint64, qint64)));
setBalance(model->getBalance(), model->getUnconfirmedBalance(), model->getImmatureBalance(), model->getAnonymizedBalance());
connect(model, SIGNAL(balanceChanged(qint64, qint64, qint64, qint64)), this, SLOT(setBalance(qint64, qint64, qint64, qint64)));
connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
}
@ -191,7 +193,7 @@ void OverviewPage::updateDisplayUnit()
if(walletModel && walletModel->getOptionsModel())
{
if(currentBalance != -1)
setBalance(currentBalance, currentUnconfirmedBalance, currentImmatureBalance);
setBalance(currentBalance, currentUnconfirmedBalance, currentImmatureBalance, currentAnonymizedBalance);
// Update txdelegate->unit with the current unit
txdelegate->unit = walletModel->getOptionsModel()->getDisplayUnit();

View File

@ -29,7 +29,7 @@ public:
void showOutOfSyncWarning(bool fShow);
public slots:
void setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance);
void setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance, qint64 anonymizedBalance);
signals:
void transactionClicked(const QModelIndex &index);
@ -41,6 +41,7 @@ private:
qint64 currentBalance;
qint64 currentUnconfirmedBalance;
qint64 currentImmatureBalance;
qint64 currentAnonymizedBalance;
TxViewDelegate *txdelegate;
TransactionFilterProxy *filter;

View File

@ -98,8 +98,8 @@ void SendCoinsDialog::setModel(WalletModel *model)
}
if(model && model->getOptionsModel())
{
setBalance(model->getBalance(), model->getUnconfirmedBalance(), model->getImmatureBalance());
connect(model, SIGNAL(balanceChanged(qint64, qint64, qint64)), this, SLOT(setBalance(qint64, qint64, qint64)));
setBalance(model->getBalance(), model->getUnconfirmedBalance(), model->getImmatureBalance(), model->getAnonymizedBalance());
connect(model, SIGNAL(balanceChanged(qint64, qint64, qint64, qint64)), this, SLOT(setBalance(qint64, qint64, qint64, qint64)));
connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
// Coin Control
@ -145,26 +145,31 @@ void SendCoinsDialog::on_sendButton_clicked()
return;
}
QString funds = "Using <b>Anonymous Funds</b>";
recipients[0].inputType = "ONLY_DENOMINATED";
if(ui->inputType->currentText() == "Use Anonymous Funds"){
recipients[0].inputType = "ONLY_NONDENOMINATED";
funds = "Using <b>Anonymous Funds</b>";
} else if(ui->inputType->currentText() == "Use Non-Anonymous Funds"){
recipients[0].inputType = "ONLY_DENOMINATED";
funds = "Using <b>NON-ANONYMOUS Funds</b>";
} else {
recipients[0].inputType = "ALL_COINS";
funds = "Using <b>ANY AVAILABLE Funds</b>";
}
// Format confirmation message
QStringList formatted;
foreach(const SendCoinsRecipient &rcp, recipients)
{
#if QT_VERSION < 0x050000
formatted.append(tr("<b>%1</b> to %2 (%3)").arg(BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, rcp.amount), Qt::escape(rcp.label), rcp.address));
formatted.append(tr("<b>%1</b> to %2 (%3) using %4").arg(BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, rcp.amount), Qt::escape(rcp.label), rcp.address, funds));
#else
formatted.append(tr("<b>%1</b> to %2 (%3)").arg(BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, rcp.amount), rcp.label.toHtmlEscaped(), rcp.address));
formatted.append(tr("<b>%1</b> to %2 (%3) using %4").arg(BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, rcp.amount), rcp.label.toHtmlEscaped(), rcp.address, funds));
#endif
}
recipients[0].inputType = "ONLY_DENOMINATED";
if(ui->inputType->currentText() == "Only Non DS+ Inputs"){
recipients[0].inputType = "ONLY_NONDENOMINATED";
} else if(ui->inputType->currentText() == "Only DS+ Inputs"){
recipients[0].inputType = "ONLY_DENOMINATED";
} else {
recipients[0].inputType = "ALL_COINS";
}
fNewRecipientAllowed = false;
@ -457,10 +462,11 @@ bool SendCoinsDialog::handleURI(const QString &uri)
return false;
}
void SendCoinsDialog::setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance)
void SendCoinsDialog::setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance, qint64 anonymizedBalance)
{
Q_UNUSED(unconfirmedBalance);
Q_UNUSED(immatureBalance);
Q_UNUSED(anonymizedBalance);
if(!model || !model->getOptionsModel())
return;

View File

@ -42,7 +42,7 @@ public slots:
void accept();
SendCoinsEntry *addEntry();
void updateRemoveEnabled();
void setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance);
void setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance, qint64 anonymizedBalance);
void setState(int state, int entries, int accepted);
private:

View File

@ -52,6 +52,12 @@ qint64 WalletModel::getBalance(const CCoinControl *coinControl) const
return wallet->GetBalance();
}
qint64 WalletModel::getAnonymizedBalance() const
{
return wallet->GetAnonymizedBalance();
}
qint64 WalletModel::getUnconfirmedBalance() const
{
return wallet->GetUnconfirmedBalance();
@ -97,13 +103,15 @@ void WalletModel::checkBalanceChanged()
qint64 newBalance = getBalance();
qint64 newUnconfirmedBalance = getUnconfirmedBalance();
qint64 newImmatureBalance = getImmatureBalance();
qint64 newAnonymizedBalance = getAnonymizedBalance();
if(cachedBalance != newBalance || cachedUnconfirmedBalance != newUnconfirmedBalance || cachedImmatureBalance != newImmatureBalance)
{
cachedBalance = newBalance;
cachedUnconfirmedBalance = newUnconfirmedBalance;
cachedImmatureBalance = newImmatureBalance;
emit balanceChanged(newBalance, newUnconfirmedBalance, newImmatureBalance);
cachedAnonymizedBalance = newAnonymizedBalance;
emit balanceChanged(newBalance, newUnconfirmedBalance, newImmatureBalance, newAnonymizedBalance);
}
}

View File

@ -65,6 +65,7 @@ public:
TransactionTableModel *getTransactionTableModel();
qint64 getBalance(const CCoinControl *coinControl=NULL) const;
qint64 getAnonymizedBalance() const;
qint64 getUnconfirmedBalance() const;
qint64 getImmatureBalance() const;
int getNumTransactions() const;
@ -142,6 +143,7 @@ private:
qint64 cachedBalance;
qint64 cachedUnconfirmedBalance;
qint64 cachedImmatureBalance;
qint64 cachedAnonymizedBalance;
qint64 cachedNumTransactions;
EncryptionStatus cachedEncryptionStatus;
int cachedNumBlocks;
@ -154,7 +156,7 @@ private:
signals:
// Signal that balance in wallet changed
void balanceChanged(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance);
void balanceChanged(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance, qint64 anonymizedBalance);
// Number of transactions in wallet changed
void numTransactionsChanged(int count);

View File

@ -75,6 +75,7 @@ Value getinfo(const Array& params, bool fHelp)
if (pwalletMain) {
obj.push_back(Pair("walletversion", pwalletMain->GetVersion()));
obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance())));
obj.push_back(Pair("anonymized_balance", ValueFromAmount(pwalletMain->GetAnonymizedBalance())));
}
obj.push_back(Pair("blocks", (int)nBestHeight));
obj.push_back(Pair("timeoffset", (boost::int64_t)GetTimeOffset()));

View File

@ -957,6 +957,32 @@ int64 CWallet::GetBalance() const
return nTotal;
}
int64 CWallet::GetAnonymizedBalance() const
{
int64 nTotal = 0;
{
LOCK(cs_wallet);
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
{
const CWalletTx* pcoin = &(*it).second;
if (pcoin->IsConfirmed()){
bool found = false;
for (unsigned int i = 0; i < pcoin->vout.size(); i++) {
COutput out = COutput(pcoin, i, pcoin->GetDepthInMainChain());
CTxIn vin = CTxIn(out.tx->GetHash(), out.i);
int rounds = darkSendPool.GetInputDarksendRounds(vin);
if(rounds >= nDarksendRounds) found = true;
}
if(found) nTotal += pcoin->GetAvailableCredit();
}
}
}
return nTotal;
}
int64 CWallet::GetNonDenominatedBalance() const
{
int64 nTotal = 0;

View File

@ -193,6 +193,7 @@ public:
void ReacceptWalletTransactions();
void ResendWalletTransactions();
int64 GetBalance() const;
int64 GetAnonymizedBalance() const;
int64 GetNonDenominatedBalance() const;
int64 GetUnconfirmedBalance() const;
int64 GetImmatureBalance() const;