diff --git a/src/interfaces/node.h b/src/interfaces/node.h --- a/src/interfaces/node.h +++ b/src/interfaces/node.h @@ -6,8 +6,11 @@ #define BITCOIN_INTERFACES_NODE_H #include // For HelpMessageMode +#include // For CConnman::NumConnections #include // For Network +#include +#include #include #include #include @@ -78,6 +81,48 @@ //! Get proxy. virtual bool getProxy(Network net, proxyType &proxy_info) = 0; + //! Get number of connections. + virtual size_t getNodeCount(CConnman::NumConnections flags) = 0; + + //! Get total bytes recv. + virtual int64_t getTotalBytesRecv() = 0; + + //! Get total bytes sent. + virtual int64_t getTotalBytesSent() = 0; + + //! Get mempool size. + virtual size_t getMempoolSize() = 0; + + //! Get mempool dynamic usage. + virtual size_t getMempoolDynamicUsage() = 0; + + //! Get header tip height and time. + virtual bool getHeaderTip(int &height, int64_t &block_time) = 0; + + //! Get num blocks. + virtual int getNumBlocks() = 0; + + //! Get last block time. + virtual int64_t getLastBlockTime() = 0; + + //! Get verification progress. + virtual double getVerificationProgress() = 0; + + //! Is initial block download. + virtual bool isInitialBlockDownload() = 0; + + //! Get reindex. + virtual bool getReindex() = 0; + + //! Get importing. + virtual bool getImporting() = 0; + + //! Set network active. + virtual void setNetworkActive(bool active) = 0; + + //! Get network active. + virtual bool getNetworkActive() = 0; + //! Register handler for init messages. using InitMessageFn = std::function; virtual std::unique_ptr handleInitMessage(InitMessageFn fn) = 0; @@ -102,6 +147,42 @@ //! Register handler for load wallet messages. using LoadWalletFn = std::function wallet)>; virtual std::unique_ptr handleLoadWallet(LoadWalletFn fn) = 0; + + //! Register handler for number of connections changed messages. + using NotifyNumConnectionsChangedFn = + std::function; + virtual std::unique_ptr + handleNotifyNumConnectionsChanged(NotifyNumConnectionsChangedFn fn) = 0; + + //! Register handler for network active messages. + using NotifyNetworkActiveChangedFn = + std::function; + virtual std::unique_ptr + handleNotifyNetworkActiveChanged(NotifyNetworkActiveChangedFn fn) = 0; + + //! Register handler for notify alert messages. + using NotifyAlertChangedFn = std::function; + virtual std::unique_ptr + handleNotifyAlertChanged(NotifyAlertChangedFn fn) = 0; + + //! Register handler for ban list messages. + using BannedListChangedFn = std::function; + virtual std::unique_ptr + handleBannedListChanged(BannedListChangedFn fn) = 0; + + //! Register handler for block tip messages. + using NotifyBlockTipFn = + std::function; + virtual std::unique_ptr + handleNotifyBlockTip(NotifyBlockTipFn fn) = 0; + + //! Register handler for header tip messages. + using NotifyHeaderTipFn = + std::function; + virtual std::unique_ptr + handleNotifyHeaderTip(NotifyHeaderTipFn fn) = 0; }; //! Return implementation of Node interface. diff --git a/src/interfaces/node.cpp b/src/interfaces/node.cpp --- a/src/interfaces/node.cpp +++ b/src/interfaces/node.cpp @@ -4,6 +4,7 @@ #include +#include #include #include #include @@ -12,9 +13,13 @@ #include #include #include +#include #include +#include +#include #include #include +#include #include #if defined(HAVE_CONFIG_H) @@ -29,6 +34,8 @@ #include +#include + class CWallet; class HTTPRPCRequestProcessor; @@ -87,6 +94,61 @@ bool getProxy(Network net, proxyType &proxy_info) override { return GetProxy(net, proxy_info); } + size_t getNodeCount(CConnman::NumConnections flags) override { + return g_connman ? g_connman->GetNodeCount(flags) : 0; + } + int64_t getTotalBytesRecv() override { + return g_connman ? g_connman->GetTotalBytesRecv() : 0; + } + int64_t getTotalBytesSent() override { + return g_connman ? g_connman->GetTotalBytesSent() : 0; + } + size_t getMempoolSize() override { return g_mempool.size(); } + size_t getMempoolDynamicUsage() override { + return g_mempool.DynamicMemoryUsage(); + } + bool getHeaderTip(int &height, int64_t &block_time) override { + LOCK(::cs_main); + if (::pindexBestHeader) { + height = ::pindexBestHeader->nHeight; + block_time = ::pindexBestHeader->GetBlockTime(); + return true; + } + return false; + } + int getNumBlocks() override { + LOCK(::cs_main); + return ::chainActive.Height(); + } + int64_t getLastBlockTime() override { + LOCK(::cs_main); + if (::chainActive.Tip()) { + return ::chainActive.Tip()->GetBlockTime(); + } + // Genesis block's time of current network + return Params().GenesisBlock().GetBlockTime(); + } + double getVerificationProgress() override { + const CBlockIndex *tip; + { + LOCK(::cs_main); + tip = ::chainActive.Tip(); + } + return GuessVerificationProgress(::Params().TxData(), tip); + } + bool isInitialBlockDownload() override { + return IsInitialBlockDownload(); + } + bool getReindex() override { return ::fReindex; } + bool getImporting() override { return ::fImporting; } + void setNetworkActive(bool active) override { + if (g_connman) { + g_connman->SetNetworkActive(active); + } + } + bool getNetworkActive() override { + return g_connman && g_connman->GetNetworkActive(); + } std::unique_ptr handleInitMessage(InitMessageFn fn) override { return MakeHandler(::uiInterface.InitMessage.connect(fn)); } @@ -104,6 +166,40 @@ CHECK_WALLET(return MakeHandler(::uiInterface.LoadWallet.connect( [fn](CWallet *wallet) { fn(MakeWallet(*wallet)); }))); } + std::unique_ptr handleNotifyNumConnectionsChanged( + NotifyNumConnectionsChangedFn fn) override { + return MakeHandler( + ::uiInterface.NotifyNumConnectionsChanged.connect(fn)); + } + std::unique_ptr handleNotifyNetworkActiveChanged( + NotifyNetworkActiveChangedFn fn) override { + return MakeHandler( + ::uiInterface.NotifyNetworkActiveChanged.connect(fn)); + } + std::unique_ptr + handleNotifyAlertChanged(NotifyAlertChangedFn fn) override { + return MakeHandler(::uiInterface.NotifyAlertChanged.connect(fn)); + } + std::unique_ptr + handleBannedListChanged(BannedListChangedFn fn) override { + return MakeHandler(::uiInterface.BannedListChanged.connect(fn)); + } + std::unique_ptr + handleNotifyBlockTip(NotifyBlockTipFn fn) override { + return MakeHandler(::uiInterface.NotifyBlockTip.connect( + [fn](bool initial_download, const CBlockIndex *block) { + fn(initial_download, block->nHeight, block->GetBlockTime(), + GuessVerificationProgress(::Params().TxData(), block)); + })); + } + std::unique_ptr + handleNotifyHeaderTip(NotifyHeaderTipFn fn) override { + return MakeHandler(::uiInterface.NotifyHeaderTip.connect( + [fn](bool initial_download, const CBlockIndex *block) { + fn(initial_download, block->nHeight, block->GetBlockTime(), + GuessVerificationProgress(::Params().TxData(), block)); + })); + } }; } // namespace diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -469,7 +469,7 @@ paymentServer->setOptionsModel(optionsModel); #endif - clientModel = new ClientModel(optionsModel); + clientModel = new ClientModel(m_node, optionsModel); window->setClientModel(clientModel); #ifdef ENABLE_WALLET diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -526,9 +526,9 @@ modalOverlay->setKnownBestHeight( _clientModel->getHeaderTipHeight(), QDateTime::fromTime_t(_clientModel->getHeaderTipTime())); - setNumBlocks(_clientModel->getNumBlocks(), - _clientModel->getLastBlockDate(), - _clientModel->getVerificationProgress(nullptr), false); + setNumBlocks(m_node.getNumBlocks(), + QDateTime::fromTime_t(m_node.getLastBlockTime()), + m_node.getVerificationProgress(), false); connect(_clientModel, SIGNAL(numBlocksChanged(int, QDateTime, double, bool)), this, SLOT(setNumBlocks(int, QDateTime, double, bool))); @@ -778,7 +778,7 @@ QString tooltip; - if (clientModel->getNetworkActive()) { + if (m_node.getNetworkActive()) { tooltip = tr("%n active connection(s) to Bitcoin network", "", count) + QString(".
") + tr("Click to disable network activity."); } else { @@ -1259,9 +1259,7 @@ } void BitcoinGUI::toggleNetworkActive() { - if (clientModel) { - clientModel->setNetworkActive(!clientModel->getNetworkActive()); - } + m_node.setNetworkActive(!m_node.getNetworkActive()); } UnitDisplayStatusBarControl::UnitDisplayStatusBarControl( diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h --- a/src/qt/clientmodel.h +++ b/src/qt/clientmodel.h @@ -9,6 +9,7 @@ #include #include +#include class AddressTableModel; class BanTableModel; @@ -19,6 +20,11 @@ class CWallet; class CBlockIndex; +namespace interfaces { +class Handler; +class Node; +} + QT_BEGIN_NAMESPACE class QTimer; QT_END_NAMESPACE @@ -37,37 +43,22 @@ Q_OBJECT public: - explicit ClientModel(OptionsModel *optionsModel, QObject *parent = 0); + explicit ClientModel(interfaces::Node &node, OptionsModel *optionsModel, + QObject *parent = 0); ~ClientModel(); + interfaces::Node &node() const { return m_node; } OptionsModel *getOptionsModel(); PeerTableModel *getPeerTableModel(); BanTableModel *getBanTableModel(); //! Return number of connections, default is in- and outbound (total) int getNumConnections(unsigned int flags = CONNECTIONS_ALL) const; - int getNumBlocks() const; int getHeaderTipHeight() const; int64_t getHeaderTipTime() const; - //! Return number of transactions in the mempool - long getMempoolSize() const; - //! Return the dynamic memory usage of the mempool - size_t getMempoolDynamicUsage() const; - - quint64 getTotalBytesRecv() const; - quint64 getTotalBytesSent() const; - - double getVerificationProgress(const CBlockIndex *tip) const; - QDateTime getLastBlockDate() const; - //! Return true if core is doing initial block download - bool inInitialBlockDownload() const; //! Returns enum BlockSource of the current importing/syncing state enum BlockSource getBlockSource() const; - //! Return true if network activity in core is enabled - bool getNetworkActive() const; - //! Toggle network activity state in core - void setNetworkActive(bool active); //! Return warnings to be displayed in status bar QString getStatusBarWarnings() const; @@ -82,6 +73,16 @@ mutable std::atomic cachedBestHeaderTime; private: + interfaces::Node &m_node; + std::unique_ptr m_handler_show_progress; + std::unique_ptr + m_handler_notify_num_connections_changed; + std::unique_ptr + m_handler_notify_network_active_changed; + std::unique_ptr m_handler_notify_alert_changed; + std::unique_ptr m_handler_banned_list_changed; + std::unique_ptr m_handler_notify_block_tip; + std::unique_ptr m_handler_notify_header_tip; OptionsModel *optionsModel; PeerTableModel *peerTableModel; BanTableModel *banTableModel; diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -14,6 +14,8 @@ #include "checkpoints.h" #include "clientversion.h" #include "config.h" +#include "interfaces/handler.h" +#include "interfaces/node.h" #include "net.h" #include "txmempool.h" #include "ui_interface.h" @@ -31,9 +33,10 @@ static int64_t nLastHeaderTipUpdateNotification = 0; static int64_t nLastBlockTipUpdateNotification = 0; -ClientModel::ClientModel(OptionsModel *_optionsModel, QObject *parent) - : QObject(parent), optionsModel(_optionsModel), peerTableModel(0), - banTableModel(0), pollTimer(0) { +ClientModel::ClientModel(interfaces::Node &node, OptionsModel *_optionsModel, + QObject *parent) + : QObject(parent), m_node(node), optionsModel(_optionsModel), + peerTableModel(0), banTableModel(0), pollTimer(0) { cachedBestHeaderHeight = -1; cachedBestHeaderTime = -1; peerTableModel = new PeerTableModel(this); @@ -60,25 +63,18 @@ connections = CConnman::CONNECTIONS_ALL; } - if (g_connman) { - return g_connman->GetNodeCount(connections); - } - return 0; -} - -int ClientModel::getNumBlocks() const { - LOCK(cs_main); - return chainActive.Height(); + return m_node.getNodeCount(connections); } int ClientModel::getHeaderTipHeight() const { if (cachedBestHeaderHeight == -1) { // make sure we initially populate the cache via a cs_main lock // otherwise we need to wait for a tip update - LOCK(cs_main); - if (pindexBestHeader) { - cachedBestHeaderHeight = pindexBestHeader->nHeight; - cachedBestHeaderTime = pindexBestHeader->GetBlockTime(); + int height; + int64_t blockTime; + if (m_node.getHeaderTip(height, blockTime)) { + cachedBestHeaderHeight = height; + cachedBestHeaderTime = blockTime; } } return cachedBestHeaderHeight; @@ -86,62 +82,22 @@ int64_t ClientModel::getHeaderTipTime() const { if (cachedBestHeaderTime == -1) { - LOCK(cs_main); - if (pindexBestHeader) { - cachedBestHeaderHeight = pindexBestHeader->nHeight; - cachedBestHeaderTime = pindexBestHeader->GetBlockTime(); + int height; + int64_t blockTime; + if (m_node.getHeaderTip(height, blockTime)) { + cachedBestHeaderHeight = height; + cachedBestHeaderTime = blockTime; } } return cachedBestHeaderTime; } -quint64 ClientModel::getTotalBytesRecv() const { - if (!g_connman) { - return 0; - } - return g_connman->GetTotalBytesRecv(); -} - -quint64 ClientModel::getTotalBytesSent() const { - if (!g_connman) { - return 0; - } - return g_connman->GetTotalBytesSent(); -} - -QDateTime ClientModel::getLastBlockDate() const { - LOCK(cs_main); - - if (chainActive.Tip()) { - return QDateTime::fromTime_t(chainActive.Tip()->GetBlockTime()); - } - - // Genesis block's time of current network - return QDateTime::fromTime_t(Params().GenesisBlock().GetBlockTime()); -} - -long ClientModel::getMempoolSize() const { - return g_mempool.size(); -} - -size_t ClientModel::getMempoolDynamicUsage() const { - return g_mempool.DynamicMemoryUsage(); -} - -double ClientModel::getVerificationProgress(const CBlockIndex *tipIn) const { - CBlockIndex *tip = const_cast(tipIn); - if (!tip) { - LOCK(cs_main); - tip = chainActive.Tip(); - } - return GuessVerificationProgress(Params().TxData(), tip); -} - void ClientModel::updateTimer() { // no locking required at this point // the following calls will acquire the required lock - Q_EMIT mempoolSizeChanged(getMempoolSize(), getMempoolDynamicUsage()); - Q_EMIT bytesChanged(getTotalBytesRecv(), getTotalBytesSent()); + Q_EMIT mempoolSizeChanged(m_node.getMempoolSize(), + m_node.getMempoolDynamicUsage()); + Q_EMIT bytesChanged(m_node.getTotalBytesRecv(), m_node.getTotalBytesSent()); } void ClientModel::updateNumConnections(int numConnections) { @@ -156,14 +112,10 @@ Q_EMIT alertsChanged(getStatusBarWarnings()); } -bool ClientModel::inInitialBlockDownload() const { - return IsInitialBlockDownload(); -} - enum BlockSource ClientModel::getBlockSource() const { - if (fReindex) { + if (m_node.getReindex()) { return BlockSource::REINDEX; - } else if (fImporting) { + } else if (m_node.getImporting()) { return BlockSource::DISK; } else if (getNumConnections() > 0) { return BlockSource::NETWORK; @@ -172,21 +124,8 @@ return BlockSource::NONE; } -void ClientModel::setNetworkActive(bool active) { - if (g_connman) { - g_connman->SetNetworkActive(active); - } -} - -bool ClientModel::getNetworkActive() const { - if (g_connman) { - return g_connman->GetNetworkActive(); - } - return false; -} - QString ClientModel::getStatusBarWarnings() const { - return QString::fromStdString(GetWarnings("gui")); + return QString::fromStdString(m_node.getWarnings("gui")); } OptionsModel *ClientModel::getOptionsModel() { @@ -261,7 +200,8 @@ } static void BlockTipChanged(ClientModel *clientmodel, bool initialSync, - const CBlockIndex *pIndex, bool fHeader) { + int height, int64_t blockTime, + double verificationProgress, bool fHeader) { // lock free async UI updates in case we have a new block tip // during initial sync, only update the UI if the last update // was > 250ms (MODEL_UPDATE_DELAY) ago @@ -276,52 +216,48 @@ if (fHeader) { // cache best headers time and height to reduce future cs_main locks - clientmodel->cachedBestHeaderHeight = pIndex->nHeight; - clientmodel->cachedBestHeaderTime = pIndex->GetBlockTime(); + clientmodel->cachedBestHeaderHeight = height; + clientmodel->cachedBestHeaderTime = blockTime; } // if we are in-sync, update the UI regardless of last update time if (!initialSync || now - nLastUpdateNotification > MODEL_UPDATE_DELAY) { // pass a async signal to the UI thread QMetaObject::invokeMethod( clientmodel, "numBlocksChanged", Qt::QueuedConnection, - Q_ARG(int, pIndex->nHeight), - Q_ARG(QDateTime, QDateTime::fromTime_t(pIndex->GetBlockTime())), - Q_ARG(double, clientmodel->getVerificationProgress(pIndex)), - Q_ARG(bool, fHeader)); + Q_ARG(int, height), + Q_ARG(QDateTime, QDateTime::fromTime_t(blockTime)), + Q_ARG(double, verificationProgress), Q_ARG(bool, fHeader)); nLastUpdateNotification = now; } } void ClientModel::subscribeToCoreSignals() { // Connect signals to client - uiInterface.ShowProgress.connect(boost::bind(ShowProgress, this, _1, _2)); - uiInterface.NotifyNumConnectionsChanged.connect( - boost::bind(NotifyNumConnectionsChanged, this, _1)); - uiInterface.NotifyNetworkActiveChanged.connect( - boost::bind(NotifyNetworkActiveChanged, this, _1)); - uiInterface.NotifyAlertChanged.connect( - boost::bind(NotifyAlertChanged, this)); - uiInterface.BannedListChanged.connect(boost::bind(BannedListChanged, this)); - uiInterface.NotifyBlockTip.connect( - boost::bind(BlockTipChanged, this, _1, _2, false)); - uiInterface.NotifyHeaderTip.connect( - boost::bind(BlockTipChanged, this, _1, _2, true)); + m_handler_show_progress = + m_node.handleShowProgress(boost::bind(ShowProgress, this, _1, _2)); + m_handler_notify_num_connections_changed = + m_node.handleNotifyNumConnectionsChanged( + boost::bind(NotifyNumConnectionsChanged, this, _1)); + m_handler_notify_network_active_changed = + m_node.handleNotifyNetworkActiveChanged( + boost::bind(NotifyNetworkActiveChanged, this, _1)); + m_handler_notify_alert_changed = + m_node.handleNotifyAlertChanged(boost::bind(NotifyAlertChanged, this)); + m_handler_banned_list_changed = + m_node.handleBannedListChanged(boost::bind(BannedListChanged, this)); + m_handler_notify_block_tip = m_node.handleNotifyBlockTip( + boost::bind(BlockTipChanged, this, _1, _2, _3, _4, false)); + m_handler_notify_header_tip = m_node.handleNotifyHeaderTip( + boost::bind(BlockTipChanged, this, _1, _2, _3, _4, true)); } void ClientModel::unsubscribeFromCoreSignals() { // Disconnect signals from client - uiInterface.ShowProgress.disconnect( - boost::bind(ShowProgress, this, _1, _2)); - uiInterface.NotifyNumConnectionsChanged.disconnect( - boost::bind(NotifyNumConnectionsChanged, this, _1)); - uiInterface.NotifyNetworkActiveChanged.disconnect( - boost::bind(NotifyNetworkActiveChanged, this, _1)); - uiInterface.NotifyAlertChanged.disconnect( - boost::bind(NotifyAlertChanged, this)); - uiInterface.BannedListChanged.disconnect( - boost::bind(BannedListChanged, this)); - uiInterface.NotifyBlockTip.disconnect( - boost::bind(BlockTipChanged, this, _1, _2, false)); - uiInterface.NotifyHeaderTip.disconnect( - boost::bind(BlockTipChanged, this, _1, _2, true)); + m_handler_show_progress->disconnect(); + m_handler_notify_num_connections_changed->disconnect(); + m_handler_notify_network_active_changed->disconnect(); + m_handler_notify_alert_changed->disconnect(); + m_handler_banned_list_changed->disconnect(); + m_handler_notify_block_tip->disconnect(); + m_handler_notify_header_tip->disconnect(); } diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -17,6 +17,7 @@ #include "chainparams.h" #include "config.h" +#include "interfaces/node.h" #include "netbase.h" #include "rpc/client.h" #include "rpc/server.h" @@ -642,8 +643,10 @@ connect(model, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int))); - setNumBlocks(model->getNumBlocks(), model->getLastBlockDate(), - model->getVerificationProgress(nullptr), false); + interfaces::Node &node = clientModel->node(); + setNumBlocks(node.getNumBlocks(), + QDateTime::fromTime_t(node.getLastBlockTime()), + node.getVerificationProgress(), false); connect(model, SIGNAL(numBlocksChanged(int, QDateTime, double, bool)), this, SLOT(setNumBlocks(int, QDateTime, double, bool))); @@ -651,8 +654,7 @@ connect(model, SIGNAL(networkActiveChanged(bool)), this, SLOT(setNetworkActive(bool))); - updateTrafficStats(model->getTotalBytesRecv(), - model->getTotalBytesSent()); + updateTrafficStats(node.getTotalBytesRecv(), node.getTotalBytesSent()); connect(model, SIGNAL(bytesChanged(quint64, quint64)), this, SLOT(updateTrafficStats(quint64, quint64))); @@ -965,7 +967,7 @@ tr("Out:") + " " + QString::number(clientModel->getNumConnections(CONNECTIONS_OUT)) + ")"; - if (!clientModel->getNetworkActive()) { + if (!clientModel->node().getNetworkActive()) { connections += " (" + tr("Network activity disabled") + ")"; } diff --git a/src/qt/trafficgraphwidget.cpp b/src/qt/trafficgraphwidget.cpp --- a/src/qt/trafficgraphwidget.cpp +++ b/src/qt/trafficgraphwidget.cpp @@ -4,6 +4,7 @@ #include "trafficgraphwidget.h" #include "clientmodel.h" +#include "interfaces/node.h" #include #include @@ -26,8 +27,8 @@ void TrafficGraphWidget::setClientModel(ClientModel *model) { clientModel = model; if (model) { - nLastBytesIn = model->getTotalBytesRecv(); - nLastBytesOut = model->getTotalBytesSent(); + nLastBytesIn = model->node().getTotalBytesRecv(); + nLastBytesOut = model->node().getTotalBytesSent(); } } @@ -111,8 +112,8 @@ void TrafficGraphWidget::updateRates() { if (!clientModel) return; - quint64 bytesIn = clientModel->getTotalBytesRecv(), - bytesOut = clientModel->getTotalBytesSent(); + quint64 bytesIn = clientModel->node().getTotalBytesRecv(), + bytesOut = clientModel->node().getTotalBytesSent(); float inRate = (bytesIn - nLastBytesIn) / 1024.0f * 1000 / timer->interval(); float outRate = @@ -157,8 +158,8 @@ fMax = 0.0f; if (clientModel) { - nLastBytesIn = clientModel->getTotalBytesRecv(); - nLastBytesOut = clientModel->getTotalBytesSent(); + nLastBytesIn = clientModel->node().getTotalBytesRecv(); + nLastBytesOut = clientModel->node().getTotalBytesSent(); } timer->start(); } diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp --- a/src/qt/walletview.cpp +++ b/src/qt/walletview.cpp @@ -19,6 +19,7 @@ #include "transactionview.h" #include "walletmodel.h" +#include "interfaces/node.h" #include "ui_interface.h" #include @@ -181,7 +182,8 @@ void WalletView::processNewTransaction(const QModelIndex &parent, int start, int end) { // Prevent balloon-spam when initial block download is in progress - if (!walletModel || !clientModel || clientModel->inInitialBlockDownload()) { + if (!walletModel || !clientModel || + clientModel->node().isInitialBlockDownload()) { return; } diff --git a/src/validation.h b/src/validation.h --- a/src/validation.h +++ b/src/validation.h @@ -426,7 +426,8 @@ * Guess verification progress (as a fraction between 0.0=genesis and * 1.0=current tip). */ -double GuessVerificationProgress(const ChainTxData &data, CBlockIndex *pindex); +double GuessVerificationProgress(const ChainTxData &data, + const CBlockIndex *pindex); /** * Calculate the amount of disk space the block & undo files currently use. diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -5688,7 +5688,8 @@ } //! Guess how far we are in the verification process at the given block index -double GuessVerificationProgress(const ChainTxData &data, CBlockIndex *pindex) { +double GuessVerificationProgress(const ChainTxData &data, + const CBlockIndex *pindex) { if (pindex == nullptr) { return 0.0; }