aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2013-01-05 07:45:02 -0800
committerWladimir J. van der Laan <laanwj@gmail.com>2013-01-05 07:45:02 -0800
commiteb5c24c4645ba69bc7a053b09e19825cdc5c9168 (patch)
treed8738b283c418822bd0a9662596181e96345ffd2 /src
parent744adb2e61641bcb0ae2e671a9c2bd74a91b7c19 (diff)
parent54413aab135aa84f60bfcb477a4d2ecfb72edbac (diff)
Merge pull request #2148 from Diapolo/est_block_count
Bitcoin-Qt: never display own block count > estimated block count
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp2
-rw-r--r--src/qt/clientmodel.cpp7
-rw-r--r--src/qt/rpcconsole.cpp9
3 files changed, 6 insertions, 12 deletions
diff --git a/src/main.cpp b/src/main.cpp
index b59e8a5aca..28fbc8b450 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -45,7 +45,7 @@ bool fReindex = false;
bool fBenchmark = false;
unsigned int nCoinCacheSize = 5000;
-CMedianFilter<int> cPeerBlockCounts(5, 0); // Amount of blocks that other nodes claim to have
+CMedianFilter<int> cPeerBlockCounts(8, 0); // Amount of blocks that other nodes claim to have
map<uint256, CBlock*> mapOrphanBlocks;
multimap<uint256, CBlock*> mapOrphanBlocksByPrev;
diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp
index ce112803f8..12bd989338 100644
--- a/src/qt/clientmodel.cpp
+++ b/src/qt/clientmodel.cpp
@@ -15,10 +15,8 @@ static const int64 nClientStartupTime = GetTime();
ClientModel::ClientModel(OptionsModel *optionsModel, QObject *parent) :
QObject(parent), optionsModel(optionsModel),
- cachedNumBlocks(0), cachedNumBlocksOfPeers(0), pollTimer(0)
+ cachedNumBlocks(0), cachedNumBlocksOfPeers(0), numBlocksAtStartup(-1), pollTimer(0)
{
- numBlocksAtStartup = -1;
-
pollTimer = new QTimer(this);
pollTimer->setInterval(MODEL_UPDATE_DELAY);
pollTimer->start();
@@ -65,7 +63,8 @@ void ClientModel::updateTimer()
cachedNumBlocks = newNumBlocks;
cachedNumBlocksOfPeers = newNumBlocksOfPeers;
- emit numBlocksChanged(newNumBlocks, newNumBlocksOfPeers);
+ // ensure we return the maximum of newNumBlocksOfPeers and newNumBlocks to not create weird displays in the GUI
+ emit numBlocksChanged(newNumBlocks, std::max(newNumBlocksOfPeers, newNumBlocks));
}
}
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp
index 3dc32d0e47..7cf2d41962 100644
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -269,8 +269,6 @@ void RPCConsole::setClientModel(ClientModel *model)
setNumConnections(model->getNumConnections());
ui->isTestNet->setChecked(model->isTestNet());
-
- setNumBlocks(model->getNumBlocks(), model->getNumBlocksOfPeers());
}
}
@@ -342,13 +340,10 @@ void RPCConsole::setNumConnections(int count)
void RPCConsole::setNumBlocks(int count, int countOfPeers)
{
ui->numberOfBlocks->setText(QString::number(count));
- ui->totalBlocks->setText(QString::number(countOfPeers));
+ // If there is no current countOfPeers available display N/A instead of 0, which can't ever be true
+ ui->totalBlocks->setText(countOfPeers == 0 ? tr("N/A") : QString::number(countOfPeers));
if(clientModel)
- {
- // If there is no current number available display N/A instead of 0, which can't ever be true
- ui->totalBlocks->setText(clientModel->getNumBlocksOfPeers() == 0 ? tr("N/A") : QString::number(clientModel->getNumBlocksOfPeers()));
ui->lastBlockTime->setText(clientModel->getLastBlockDate().toString());
- }
}
void RPCConsole::on_lineEdit_returnPressed()