Bitcoin-Qt: never display own block count > estimated block count

- some users reported it as weird, that the estimated block count could be
  lower than our own nodes block number (which is indeed true and not good)
- this pull adds a new default behaviour, which displays our own block
  number as estimated block number, if own >= est. block count
- the pull raises space for nodes block counts in cPeerBlockCounts to 8 to
  be more accurate
- also removes a reduntant setNumBlocks() call in RPCConsole and moves
  initialisation of numBlocksAtStartup in ClientModel, where it belongs
This commit is contained in:
Philip Kaufmann 2013-01-03 22:13:24 +01:00
parent ea9788517b
commit 54413aab13
3 changed files with 6 additions and 12 deletions

View File

@ -45,7 +45,7 @@ bool fReindex = false;
bool fBenchmark = false; bool fBenchmark = false;
unsigned int nCoinCacheSize = 5000; 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; map<uint256, CBlock*> mapOrphanBlocks;
multimap<uint256, CBlock*> mapOrphanBlocksByPrev; multimap<uint256, CBlock*> mapOrphanBlocksByPrev;

View File

@ -15,10 +15,8 @@ static const int64 nClientStartupTime = GetTime();
ClientModel::ClientModel(OptionsModel *optionsModel, QObject *parent) : ClientModel::ClientModel(OptionsModel *optionsModel, QObject *parent) :
QObject(parent), optionsModel(optionsModel), 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 = new QTimer(this);
pollTimer->setInterval(MODEL_UPDATE_DELAY); pollTimer->setInterval(MODEL_UPDATE_DELAY);
pollTimer->start(); pollTimer->start();
@ -65,7 +63,8 @@ void ClientModel::updateTimer()
cachedNumBlocks = newNumBlocks; cachedNumBlocks = newNumBlocks;
cachedNumBlocksOfPeers = newNumBlocksOfPeers; 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));
} }
} }

View File

@ -269,8 +269,6 @@ void RPCConsole::setClientModel(ClientModel *model)
setNumConnections(model->getNumConnections()); setNumConnections(model->getNumConnections());
ui->isTestNet->setChecked(model->isTestNet()); 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) void RPCConsole::setNumBlocks(int count, int countOfPeers)
{ {
ui->numberOfBlocks->setText(QString::number(count)); 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(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()); ui->lastBlockTime->setText(clientModel->getLastBlockDate().toString());
}
} }
void RPCConsole::on_lineEdit_returnPressed() void RPCConsole::on_lineEdit_returnPressed()