On initial block chain download, show a progress bar
This commit is contained in:
parent
0eeb4f5d5b
commit
6cab66354d
16
src/main.cpp
16
src/main.cpp
@ -25,6 +25,7 @@ map<COutPoint, CInPoint> mapNextTx;
|
|||||||
map<uint256, CBlockIndex*> mapBlockIndex;
|
map<uint256, CBlockIndex*> mapBlockIndex;
|
||||||
uint256 hashGenesisBlock("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f");
|
uint256 hashGenesisBlock("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f");
|
||||||
CBigNum bnProofOfWorkLimit(~uint256(0) >> 32);
|
CBigNum bnProofOfWorkLimit(~uint256(0) >> 32);
|
||||||
|
const int nTotalBlocksEstimate = 131000; // Conservative estimate of total nr of blocks on main chain
|
||||||
CBlockIndex* pindexGenesisBlock = NULL;
|
CBlockIndex* pindexGenesisBlock = NULL;
|
||||||
int nBestHeight = -1;
|
int nBestHeight = -1;
|
||||||
CBigNum bnBestChainWork = 0;
|
CBigNum bnBestChainWork = 0;
|
||||||
@ -1156,9 +1157,22 @@ bool CheckProofOfWork(uint256 hash, unsigned int nBits)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return conservative estimate of total number of blocks, 0 if unknown
|
||||||
|
int GetTotalBlocksEstimate()
|
||||||
|
{
|
||||||
|
if(fTestNet)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return nTotalBlocksEstimate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool IsInitialBlockDownload()
|
bool IsInitialBlockDownload()
|
||||||
{
|
{
|
||||||
if (pindexBest == NULL || (!fTestNet && nBestHeight < 118000))
|
if (pindexBest == NULL || nBestHeight < GetTotalBlocksEstimate())
|
||||||
return true;
|
return true;
|
||||||
static int64 nLastUpdate;
|
static int64 nLastUpdate;
|
||||||
static CBlockIndex* pindexLastBest;
|
static CBlockIndex* pindexLastBest;
|
||||||
|
@ -118,6 +118,7 @@ void FormatHashBuffers(CBlock* pblock, char* pmidstate, char* pdata, char* phash
|
|||||||
bool CheckWork(CBlock* pblock, CReserveKey& reservekey);
|
bool CheckWork(CBlock* pblock, CReserveKey& reservekey);
|
||||||
void BitcoinMiner();
|
void BitcoinMiner();
|
||||||
bool CheckProofOfWork(uint256 hash, unsigned int nBits);
|
bool CheckProofOfWork(uint256 hash, unsigned int nBits);
|
||||||
|
int GetTotalBlocksEstimate();
|
||||||
bool IsInitialBlockDownload();
|
bool IsInitialBlockDownload();
|
||||||
std::string GetWarnings(std::string strFor);
|
std::string GetWarnings(std::string strFor);
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QProgressBar>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
@ -124,6 +125,15 @@ BitcoinGUI::BitcoinGUI(QWidget *parent):
|
|||||||
labelTransactions->setMinimumWidth(130);
|
labelTransactions->setMinimumWidth(130);
|
||||||
labelTransactions->setToolTip(tr("Number of transactions in your wallet"));
|
labelTransactions->setToolTip(tr("Number of transactions in your wallet"));
|
||||||
|
|
||||||
|
// Progress bar for blocks download
|
||||||
|
progressBarLabel = new QLabel(tr("Downloading initial data..."));
|
||||||
|
progressBarLabel->setVisible(false);
|
||||||
|
progressBar = new QProgressBar();
|
||||||
|
progressBar->setToolTip(tr("Initial block chain download in progress"));
|
||||||
|
progressBar->setVisible(false);
|
||||||
|
|
||||||
|
statusBar()->addWidget(progressBarLabel);
|
||||||
|
statusBar()->addWidget(progressBar);
|
||||||
statusBar()->addPermanentWidget(labelConnections);
|
statusBar()->addPermanentWidget(labelConnections);
|
||||||
statusBar()->addPermanentWidget(labelBlocks);
|
statusBar()->addPermanentWidget(labelBlocks);
|
||||||
statusBar()->addPermanentWidget(labelTransactions);
|
statusBar()->addPermanentWidget(labelTransactions);
|
||||||
@ -360,6 +370,20 @@ void BitcoinGUI::setNumConnections(int count)
|
|||||||
|
|
||||||
void BitcoinGUI::setNumBlocks(int count)
|
void BitcoinGUI::setNumBlocks(int count)
|
||||||
{
|
{
|
||||||
|
int total = model->getTotalBlocksEstimate();
|
||||||
|
if(count < total)
|
||||||
|
{
|
||||||
|
progressBarLabel->setVisible(true);
|
||||||
|
progressBar->setVisible(true);
|
||||||
|
progressBar->setMaximum(total);
|
||||||
|
progressBar->setValue(count);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
progressBarLabel->setVisible(false);
|
||||||
|
progressBar->setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
labelBlocks->setText(QLocale::system().toString(count)+" "+tr("block(s)", "", count));
|
labelBlocks->setText(QLocale::system().toString(count)+" "+tr("block(s)", "", count));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ class QLineEdit;
|
|||||||
class QTableView;
|
class QTableView;
|
||||||
class QAbstractItemModel;
|
class QAbstractItemModel;
|
||||||
class QModelIndex;
|
class QModelIndex;
|
||||||
|
class QProgressBar;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
class BitcoinGUI : public QMainWindow
|
class BitcoinGUI : public QMainWindow
|
||||||
@ -43,6 +44,8 @@ private:
|
|||||||
QLabel *labelConnectionsIcon;
|
QLabel *labelConnectionsIcon;
|
||||||
QLabel *labelBlocks;
|
QLabel *labelBlocks;
|
||||||
QLabel *labelTransactions;
|
QLabel *labelTransactions;
|
||||||
|
QLabel *progressBarLabel;
|
||||||
|
QProgressBar *progressBar;
|
||||||
|
|
||||||
QAction *quit;
|
QAction *quit;
|
||||||
QAction *sendcoins;
|
QAction *sendcoins;
|
||||||
|
@ -143,6 +143,12 @@ bool ClientModel::inInitialBlockDownload() const
|
|||||||
return IsInitialBlockDownload();
|
return IsInitialBlockDownload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ClientModel::getTotalBlocksEstimate() const
|
||||||
|
{
|
||||||
|
return GetTotalBlocksEstimate();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
OptionsModel *ClientModel::getOptionsModel()
|
OptionsModel *ClientModel::getOptionsModel()
|
||||||
{
|
{
|
||||||
return optionsModel;
|
return optionsModel;
|
||||||
|
@ -36,6 +36,8 @@ public:
|
|||||||
|
|
||||||
/* Return true if core is doing initial block download */
|
/* Return true if core is doing initial block download */
|
||||||
bool inInitialBlockDownload() const;
|
bool inInitialBlockDownload() const;
|
||||||
|
/* Return conservative estimate of total number of blocks, or 0 if unknown */
|
||||||
|
int getTotalBlocksEstimate() const;
|
||||||
|
|
||||||
/* Set default address */
|
/* Set default address */
|
||||||
void setAddress(const QString &defaultAddress);
|
void setAddress(const QString &defaultAddress);
|
||||||
|
Loading…
Reference in New Issue
Block a user