Skip to content

Commit a0d0f1c

Browse files
committed
refactor: Remove Node:: queries from GUI
1 parent 06d519f commit a0d0f1c

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/qt/bitcoingui.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <ui_interface.h>
3838
#include <util/system.h>
3939
#include <util/translation.h>
40+
#include <validation.h>
4041

4142
#include <QAction>
4243
#include <QApplication>
@@ -567,7 +568,7 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel)
567568
connect(_clientModel, &ClientModel::networkActiveChanged, this, &BitcoinGUI::setNetworkActive);
568569

569570
modalOverlay->setKnownBestHeight(_clientModel->getHeaderTipHeight(), QDateTime::fromTime_t(_clientModel->getHeaderTipTime()));
570-
setNumBlocks(m_node.getNumBlocks(), QDateTime::fromTime_t(m_node.getLastBlockTime()), m_node.getVerificationProgress(), false);
571+
setNumBlocks(m_node.getNumBlocks(), QDateTime::fromTime_t(m_node.getLastBlockTime()), m_node.getVerificationProgress(), false, SynchronizationState::INIT_DOWNLOAD);
571572
connect(_clientModel, &ClientModel::numBlocksChanged, this, &BitcoinGUI::setNumBlocks);
572573

573574
// Receive and report messages from client model
@@ -926,11 +927,15 @@ void BitcoinGUI::openOptionsDialogWithTab(OptionsDialog::Tab tab)
926927
dlg.exec();
927928
}
928929

929-
void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool header)
930+
void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool header, SynchronizationState sync_state)
930931
{
931932
// Disabling macOS App Nap on initial sync, disk and reindex operations.
932933
#ifdef Q_OS_MAC
933-
(m_node.isInitialBlockDownload() || m_node.getReindex() || m_node.getImporting()) ? m_app_nap_inhibitor->disableAppNap() : m_app_nap_inhibitor->enableAppNap();
934+
if (sync_state == SynchronizationState::POST_INIT) {
935+
m_app_nap_inhibitor->enableAppNap();
936+
} else {
937+
m_app_nap_inhibitor->disableAppNap();
938+
}
934939
#endif
935940

936941
if (modalOverlay)

src/qt/bitcoingui.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class WalletFrame;
3838
class WalletModel;
3939
class HelpMessageDialog;
4040
class ModalOverlay;
41+
enum class SynchronizationState;
4142

4243
namespace interfaces {
4344
class Handler;
@@ -213,7 +214,7 @@ public Q_SLOTS:
213214
/** Set network state shown in the UI */
214215
void setNetworkActive(bool networkActive);
215216
/** Set number of blocks and last block date shown in the UI */
216-
void setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool headers);
217+
void setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool headers, SynchronizationState sync_state);
217218

218219
/** Notify the user of an event from the core network or transaction handling code.
219220
@param[in] title the message box / notification title

0 commit comments

Comments
 (0)