Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove reindex special case from the progress bar label #697

Merged
merged 1 commit into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/interfaces/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,8 @@ class Node
//! Is initial block download.
virtual bool isInitialBlockDownload() = 0;

//! Get reindex.
virtual bool getReindex() = 0;

//! Get importing.
virtual bool getImporting() = 0;
//! Is loading blocks.
virtual bool isLoadingBlocks() = 0;

//! Set network active.
virtual void setNetworkActive(bool active) = 0;
Expand Down
3 changes: 1 addition & 2 deletions src/node/interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,7 @@ class NodeImpl : public Node
bool isInitialBlockDownload() override {
return chainman().ActiveChainstate().IsInitialBlockDownload();
}
bool getReindex() override { return node::fReindex; }
bool getImporting() override { return node::fImporting; }
bool isLoadingBlocks() override { return node::fReindex || node::fImporting; }
void setNetworkActive(bool active) override
{
if (m_context->connman) {
Expand Down
5 changes: 1 addition & 4 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer
statusBar()->clearMessage();

// Acquire current block source
enum BlockSource blockSource = clientModel->getBlockSource();
BlockSource blockSource{clientModel->getBlockSource()};
switch (blockSource) {
case BlockSource::NETWORK:
if (synctype == SyncType::HEADER_PRESYNC) {
Expand All @@ -1091,9 +1091,6 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer
progressBarLabel->setText(tr("Processing blocks on disk…"));
}
break;
case BlockSource::REINDEX:
progressBarLabel->setText(tr("Reindexing blocks on disk…"));
break;
case BlockSource::NONE:
if (synctype != SyncType::BLOCK_SYNC) {
return;
Expand Down
11 changes: 3 additions & 8 deletions src/qt/clientmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,10 @@ uint256 ClientModel::getBestBlockHash()
return m_cached_tip_blocks;
}

enum BlockSource ClientModel::getBlockSource() const
BlockSource ClientModel::getBlockSource() const
{
if (m_node.getReindex())
return BlockSource::REINDEX;
else if (m_node.getImporting())
return BlockSource::DISK;
else if (getNumConnections() > 0)
return BlockSource::NETWORK;

if (m_node.isLoadingBlocks()) return BlockSource::DISK;
if (getNumConnections() > 0) return BlockSource::NETWORK;
Comment on lines +151 to +152
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this, somehow else following return (or break, continue) doesn't seem right.

return BlockSource::NONE;
}

Expand Down
7 changes: 3 additions & 4 deletions src/qt/clientmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ QT_END_NAMESPACE

enum class BlockSource {
NONE,
REINDEX,
DISK,
NETWORK
NETWORK,
};

enum class SyncType {
Expand Down Expand Up @@ -72,8 +71,8 @@ class ClientModel : public QObject
int getHeaderTipHeight() const;
int64_t getHeaderTipTime() const;

//! Returns enum BlockSource of the current importing/syncing state
enum BlockSource getBlockSource() const;
//! Returns the block source of the current importing/syncing state
BlockSource getBlockSource() const;
//! Return warnings to be displayed in status bar
QString getStatusBarWarnings() const;

Expand Down