map<uint256, CBlockIndex*> mapBlockIndex;
uint256 hashGenesisBlock("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f");
CBigNum bnProofOfWorkLimit(~uint256(0) >> 32);
-const int nTotalBlocksEstimate = 134444; // Conservative estimate of total nr of blocks on main chain
+int nTotalBlocksEstimate = 134444; // Conservative estimate of total nr of blocks on main chain
const int nInitialBlockThreshold = 120; // Regard blocks up until N-threshold as "initial download"
CBlockIndex* pindexGenesisBlock = NULL;
int nBestHeight = -1;
pfrom->fSuccessfullyConnected = true;
printf("version message: version %d, blocks=%d\n", pfrom->nVersion, pfrom->nStartingHeight);
+ if(pfrom->nStartingHeight > nTotalBlocksEstimate)
+ {
+ nTotalBlocksEstimate = pfrom->nStartingHeight;
+ }
}
void BitcoinGUI::setNumBlocks(int count)
{
int total = clientModel->getTotalBlocksEstimate();
+ QString tooltip;
+
if(count < total)
{
progressBarLabel->setVisible(true);
progressBar->setVisible(true);
progressBar->setMaximum(total);
progressBar->setValue(count);
+ tooltip = tr("Downloaded %1 of %2 blocks of transaction history.").arg(count).arg(total);
}
else
{
progressBarLabel->setVisible(false);
progressBar->setVisible(false);
+ tooltip = tr("Downloaded %1 blocks of transaction history.").arg(count);
}
QDateTime now = QDateTime::currentDateTime();
{
text = tr("%n day(s) ago","",secs/(60*60*24));
}
+ tooltip += QString("\n");
+ tooltip += tr("Last block was generated %1.").arg(QLocale::system().toString(lastBlockDate));
labelBlocks->setText("<img src=\""+icon+"\"> " + text);
- labelBlocks->setToolTip(tr("Downloaded %n block(s) of transaction history. Last block was generated %1.", "", count)
- .arg(QLocale::system().toString(lastBlockDate)));
+ labelBlocks->setToolTip(tooltip);
+ progressBarLabel->setToolTip(tooltip);
+ progressBar->setToolTip(tooltip);
}
void BitcoinGUI::error(const QString &title, const QString &message)
#include <QDateTime>
ClientModel::ClientModel(CWallet *wallet, QObject *parent) :
- QObject(parent), wallet(wallet), optionsModel(0)
+ QObject(parent), wallet(wallet), optionsModel(0),
+ cachedNumConnections(0), cachedNumBlocks(0)
{
// Until signal notifications is built into the bitcoin core,
// simply update everything after polling using a timer.
void ClientModel::update()
{
- // Plainly emit all signals for now. To be more efficient this should check
- // whether the values actually changed first, although it'd be even better if these
- // were events coming in from the bitcoin core.
- emit numConnectionsChanged(getNumConnections());
- emit numBlocksChanged(getNumBlocks());
+ int newNumConnections = getNumConnections();
+ int newNumBlocks = getNumBlocks();
+
+ if(cachedNumConnections != newNumConnections)
+ emit numConnectionsChanged(newNumConnections);
+ if(cachedNumBlocks != newNumBlocks)
+ emit numBlocksChanged(newNumBlocks);
+
+ cachedNumConnections = newNumConnections;
+ cachedNumBlocks = newNumBlocks;
}
bool ClientModel::isTestNet() const
OptionsModel *optionsModel;
+ int cachedNumConnections;
+ int cachedNumBlocks;
+
signals:
void numConnectionsChanged(int count);
void numBlocksChanged(int count);
#define GUICONSTANTS_H
/* milliseconds between model updates */
-static const int MODEL_UPDATE_DELAY = 250;
+static const int MODEL_UPDATE_DELAY = 500;
/* size of cache */
static const unsigned int WALLET_CACHE_SIZE = 100;
WalletModel::WalletModel(CWallet *wallet, QObject *parent) :
QObject(parent), wallet(wallet), optionsModel(0), addressTableModel(0),
- transactionTableModel(0)
+ transactionTableModel(0),
+ cachedBalance(0), cachedUnconfirmedBalance(0), cachedNumTransactions(0)
{
// Until signal notifications is built into the bitcoin core,
// simply update everything after polling using a timer.
void WalletModel::update()
{
- // Plainly emit all signals for now. To be more efficient this should check
- // whether the values actually changed first, although it'd be even better if these
- // were events coming in from the bitcoin core.
- emit balanceChanged(getBalance(), wallet->GetUnconfirmedBalance());
- emit numTransactionsChanged(getNumTransactions());
+ qint64 newBalance = getBalance();
+ qint64 newUnconfirmedBalance = getUnconfirmedBalance();
+ int newNumTransactions = getNumTransactions();
+
+ if(cachedBalance != newBalance || cachedUnconfirmedBalance != newUnconfirmedBalance)
+ emit balanceChanged(newBalance, newUnconfirmedBalance);
+
+ if(cachedNumTransactions != newNumTransactions)
+ emit numTransactionsChanged(newNumTransactions);
+
+ cachedBalance = newBalance;
+ cachedUnconfirmedBalance = newUnconfirmedBalance;
+ cachedNumTransactions = newNumTransactions;
addressTableModel->update();
}
AddressTableModel *addressTableModel;
TransactionTableModel *transactionTableModel;
+ qint64 cachedBalance;
+ qint64 cachedUnconfirmedBalance;
+ qint64 cachedNumTransactions;
+
signals:
void balanceChanged(qint64 balance, qint64 unconfirmedBalance);
void numTransactionsChanged(int count);