Skip to content

Commit

Permalink
GUI: topbar, removing not used block source.
Browse files Browse the repository at this point in the history
ClientModel::getBlockSource is locking cs_nodes every second and the result is currently not used.
  • Loading branch information
furszy committed Mar 11, 2021
1 parent e9c160a commit ef77fdf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 21 deletions.
5 changes: 5 additions & 0 deletions src/qt/clientmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ int64_t ClientModel::getLastBlockProcessedTime() const
return cacheTip == nullptr ? Params().GenesisBlock().GetBlockTime() : cacheTip->GetBlockTime();
}

bool ClientModel::isTipCached() const
{
return cacheTip;
}

double ClientModel::getVerificationProgress() const
{
return Checkpoints::GuessVerificationProgress(cacheTip);
Expand Down
1 change: 1 addition & 0 deletions src/qt/clientmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class ClientModel : public QObject
int getLastBlockProcessedHeight() const;
int64_t getLastBlockProcessedTime() const;
double getVerificationProgress() const;
bool isTipCached() const;

quint64 getTotalBytesRecv() const;
quint64 getTotalBytesSent() const;
Expand Down
23 changes: 2 additions & 21 deletions src/qt/pivx/topbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,26 +474,7 @@ void TopBar::setNumBlocks(int count)
if (!clientModel)
return;

// Acquire current block source
enum BlockSource blockSource = clientModel->getBlockSource();
std::string text = "";
switch (blockSource) {
case BLOCK_SOURCE_NETWORK:
text = "Synchronizing..";
break;
case BLOCK_SOURCE_DISK:
text = "Importing blocks from disk..";
break;
case BLOCK_SOURCE_REINDEX:
text = "Reindexing blocks on disk..";
break;
case BLOCK_SOURCE_NONE:
// Case: not Importing, not Reindexing and no network connection
text = "No block source available..";
ui->pushButtonSync->setChecked(false);
break;
}

std::string text;
bool needState = true;
if (masternodeSync.IsBlockchainSynced()) {
// chain synced
Expand Down Expand Up @@ -523,7 +504,7 @@ void TopBar::setNumBlocks(int count)
Q_EMIT walletSynced(false);
}

if (needState) {
if (needState && clientModel->isTipCached()) {
// Represent time from last generated block in human readable text
QDateTime lastBlockDate = clientModel->getLastBlockDate();
QDateTime currentDate = QDateTime::currentDateTime();
Expand Down

0 comments on commit ef77fdf

Please sign in to comment.