Changeset View
Changeset View
Standalone View
Standalone View
src/qt/clientmodel.h
// Copyright (c) 2011-2016 The Bitcoin Core developers | // Copyright (c) 2011-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#ifndef BITCOIN_QT_CLIENTMODEL_H | #ifndef BITCOIN_QT_CLIENTMODEL_H | ||||
#define BITCOIN_QT_CLIENTMODEL_H | #define BITCOIN_QT_CLIENTMODEL_H | ||||
#include <QDateTime> | #include <QDateTime> | ||||
#include <QObject> | #include <QObject> | ||||
#include <atomic> | #include <atomic> | ||||
#include <memory> | |||||
class AddressTableModel; | class AddressTableModel; | ||||
class BanTableModel; | class BanTableModel; | ||||
class OptionsModel; | class OptionsModel; | ||||
class PeerTableModel; | class PeerTableModel; | ||||
class TransactionTableModel; | class TransactionTableModel; | ||||
class CWallet; | class CWallet; | ||||
class CBlockIndex; | class CBlockIndex; | ||||
namespace interfaces { | |||||
class Handler; | |||||
class Node; | |||||
} | |||||
QT_BEGIN_NAMESPACE | QT_BEGIN_NAMESPACE | ||||
class QTimer; | class QTimer; | ||||
QT_END_NAMESPACE | QT_END_NAMESPACE | ||||
enum class BlockSource { NONE, REINDEX, DISK, NETWORK }; | enum class BlockSource { NONE, REINDEX, DISK, NETWORK }; | ||||
enum NumConnections { | enum NumConnections { | ||||
CONNECTIONS_NONE = 0, | CONNECTIONS_NONE = 0, | ||||
CONNECTIONS_IN = (1U << 0), | CONNECTIONS_IN = (1U << 0), | ||||
CONNECTIONS_OUT = (1U << 1), | CONNECTIONS_OUT = (1U << 1), | ||||
CONNECTIONS_ALL = (CONNECTIONS_IN | CONNECTIONS_OUT), | CONNECTIONS_ALL = (CONNECTIONS_IN | CONNECTIONS_OUT), | ||||
}; | }; | ||||
/** Model for Bitcoin network client. */ | /** Model for Bitcoin network client. */ | ||||
class ClientModel : public QObject { | class ClientModel : public QObject { | ||||
Q_OBJECT | Q_OBJECT | ||||
public: | public: | ||||
explicit ClientModel(OptionsModel *optionsModel, QObject *parent = 0); | explicit ClientModel(interfaces::Node &node, OptionsModel *optionsModel, | ||||
QObject *parent = 0); | |||||
~ClientModel(); | ~ClientModel(); | ||||
interfaces::Node &node() const { return m_node; } | |||||
OptionsModel *getOptionsModel(); | OptionsModel *getOptionsModel(); | ||||
PeerTableModel *getPeerTableModel(); | PeerTableModel *getPeerTableModel(); | ||||
BanTableModel *getBanTableModel(); | BanTableModel *getBanTableModel(); | ||||
//! Return number of connections, default is in- and outbound (total) | //! Return number of connections, default is in- and outbound (total) | ||||
int getNumConnections(unsigned int flags = CONNECTIONS_ALL) const; | int getNumConnections(unsigned int flags = CONNECTIONS_ALL) const; | ||||
int getNumBlocks() const; | |||||
int getHeaderTipHeight() const; | int getHeaderTipHeight() const; | ||||
int64_t getHeaderTipTime() 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 | //! Returns enum BlockSource of the current importing/syncing state | ||||
enum BlockSource getBlockSource() const; | 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 | //! Return warnings to be displayed in status bar | ||||
QString getStatusBarWarnings() const; | QString getStatusBarWarnings() const; | ||||
QString formatFullVersion() const; | QString formatFullVersion() const; | ||||
QString formatSubVersion() const; | QString formatSubVersion() const; | ||||
bool isReleaseVersion() const; | bool isReleaseVersion() const; | ||||
QString formatClientStartupTime() const; | QString formatClientStartupTime() const; | ||||
QString dataDir() const; | QString dataDir() const; | ||||
// caches for the best header | // caches for the best header | ||||
mutable std::atomic<int> cachedBestHeaderHeight; | mutable std::atomic<int> cachedBestHeaderHeight; | ||||
mutable std::atomic<int64_t> cachedBestHeaderTime; | mutable std::atomic<int64_t> cachedBestHeaderTime; | ||||
private: | private: | ||||
interfaces::Node &m_node; | |||||
std::unique_ptr<interfaces::Handler> m_handler_show_progress; | |||||
std::unique_ptr<interfaces::Handler> | |||||
m_handler_notify_num_connections_changed; | |||||
std::unique_ptr<interfaces::Handler> | |||||
m_handler_notify_network_active_changed; | |||||
std::unique_ptr<interfaces::Handler> m_handler_notify_alert_changed; | |||||
std::unique_ptr<interfaces::Handler> m_handler_banned_list_changed; | |||||
std::unique_ptr<interfaces::Handler> m_handler_notify_block_tip; | |||||
std::unique_ptr<interfaces::Handler> m_handler_notify_header_tip; | |||||
OptionsModel *optionsModel; | OptionsModel *optionsModel; | ||||
PeerTableModel *peerTableModel; | PeerTableModel *peerTableModel; | ||||
BanTableModel *banTableModel; | BanTableModel *banTableModel; | ||||
QTimer *pollTimer; | QTimer *pollTimer; | ||||
void subscribeToCoreSignals(); | void subscribeToCoreSignals(); | ||||
void unsubscribeFromCoreSignals(); | void unsubscribeFromCoreSignals(); | ||||
Show All 26 Lines |