Dogecoin Core  1.14.2
P2P Digital Currency
clientmodel.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2016 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_QT_CLIENTMODEL_H
6 #define BITCOIN_QT_CLIENTMODEL_H
7 
8 #include <QObject>
9 #include <QDateTime>
10 
11 #include <atomic>
12 
13 class AddressTableModel;
14 class BanTableModel;
15 class OptionsModel;
16 class PeerTableModel;
18 
19 class CWallet;
20 class CBlockIndex;
21 
22 QT_BEGIN_NAMESPACE
23 class QTimer;
24 QT_END_NAMESPACE
25 
31 };
32 
35  CONNECTIONS_IN = (1U << 0),
36  CONNECTIONS_OUT = (1U << 1),
38 };
39 
41 class ClientModel : public QObject
42 {
43  Q_OBJECT
44 
45 public:
46  explicit ClientModel(OptionsModel *optionsModel, QObject *parent = 0);
47  ~ClientModel();
48 
52 
54  int getNumConnections(unsigned int flags = CONNECTIONS_ALL) const;
55  int getNumBlocks() const;
56  int getHeaderTipHeight() const;
57  int64_t getHeaderTipTime() const;
59  long getMempoolSize() const;
61  size_t getMempoolDynamicUsage() const;
62 
63  quint64 getTotalBytesRecv() const;
64  quint64 getTotalBytesSent() const;
65 
66  double getVerificationProgress(const CBlockIndex *tip) const;
67  QDateTime getLastBlockDate() const;
68 
70  bool inInitialBlockDownload() const;
72  enum BlockSource getBlockSource() const;
74  bool getNetworkActive() const;
76  void setNetworkActive(bool active);
78  QString getStatusBarWarnings() const;
79 
80  QString formatFullVersion() const;
81  QString formatSubVersion() const;
82  bool isReleaseVersion() const;
83  QString formatClientStartupTime() const;
84  QString dataDir() const;
85 
86  // caches for the best header
87  mutable std::atomic<int> cachedBestHeaderHeight;
88  mutable std::atomic<int64_t> cachedBestHeaderTime;
89 
90 private:
94 
95  QTimer *pollTimer;
96 
99 
100 Q_SIGNALS:
101  void numConnectionsChanged(int count);
102  void numBlocksChanged(int count, const QDateTime& blockDate, double nVerificationProgress, bool header);
103  void mempoolSizeChanged(long count, size_t mempoolSizeInBytes);
104  void networkActiveChanged(bool networkActive);
105  void alertsChanged(const QString &warnings);
106  void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut);
107 
109  void message(const QString &title, const QString &message, unsigned int style);
110 
111  // Show progress dialog e.g. for verifychain
112  void showProgress(const QString &title, int nProgress);
113 
114 public Q_SLOTS:
115  void updateTimer();
116  void updateNumConnections(int numConnections);
117  void updateNetworkActive(bool networkActive);
118  void updateAlert(const QString &hash, int status);
119  void updateBanlist();
120 };
121 
122 #endif // BITCOIN_QT_CLIENTMODEL_H
int flags
Definition: bitcoin-tx.cpp:468
Qt model of the address book in the core.
Qt model providing information about connected peers, similar to the "getpeerinfo" RPC call.
Definition: bantablemodel.h:38
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:158
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances,...
Definition: wallet.h:493
Model for Bitcoin network client.
Definition: clientmodel.h:42
void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut)
void updateBanlist()
void showProgress(const QString &title, int nProgress)
void setNetworkActive(bool active)
Toggle network activity state in core.
QString getStatusBarWarnings() const
Return warnings to be displayed in status bar.
void updateAlert(const QString &hash, int status)
int getHeaderTipHeight() const
Definition: clientmodel.cpp:80
std::atomic< int64_t > cachedBestHeaderTime
Definition: clientmodel.h:88
void numBlocksChanged(int count, const QDateTime &blockDate, double nVerificationProgress, bool header)
quint64 getTotalBytesRecv() const
quint64 getTotalBytesSent() const
PeerTableModel * getPeerTableModel()
void updateNetworkActive(bool networkActive)
std::atomic< int > cachedBestHeaderHeight
Definition: clientmodel.h:87
void updateNumConnections(int numConnections)
size_t getMempoolDynamicUsage() const
Return the dynamic memory usage of the mempool.
void updateTimer()
void message(const QString &title, const QString &message, unsigned int style)
Fired when a message should be reported to the user.
QDateTime getLastBlockDate() const
void numConnectionsChanged(int count)
int getNumBlocks() const
Definition: clientmodel.cpp:74
int64_t getHeaderTipTime() const
Definition: clientmodel.cpp:94
double getVerificationProgress(const CBlockIndex *tip) const
bool getNetworkActive() const
Return true if network activity in core is enabled.
QString formatClientStartupTime() const
int getNumConnections(unsigned int flags=CONNECTIONS_ALL) const
Return number of connections, default is in- and outbound (total)
Definition: clientmodel.cpp:58
enum BlockSource getBlockSource() const
Returns enum BlockSource of the current importing/syncing state.
OptionsModel * optionsModel
Definition: clientmodel.h:91
BanTableModel * banTableModel
Definition: clientmodel.h:93
BanTableModel * getBanTableModel()
void unsubscribeFromCoreSignals()
long getMempoolSize() const
Return number of transactions in the mempool.
QTimer * pollTimer
Definition: clientmodel.h:95
void alertsChanged(const QString &warnings)
QString dataDir() const
OptionsModel * getOptionsModel()
QString formatFullVersion() const
PeerTableModel * peerTableModel
Definition: clientmodel.h:92
ClientModel(OptionsModel *optionsModel, QObject *parent=0)
Definition: clientmodel.cpp:35
QString formatSubVersion() const
void mempoolSizeChanged(long count, size_t mempoolSizeInBytes)
bool isReleaseVersion() const
bool inInitialBlockDownload() const
Return true if core is doing initial block download.
void subscribeToCoreSignals()
void networkActiveChanged(bool networkActive)
Interface from Qt to configuration data structure for Bitcoin client.
Definition: optionsmodel.h:23
Qt model providing information about connected peers, similar to the "getpeerinfo" RPC call.
UI model for the transaction table of a wallet.
NumConnections
Definition: clientmodel.h:33
@ CONNECTIONS_IN
Definition: clientmodel.h:35
@ CONNECTIONS_NONE
Definition: clientmodel.h:34
@ CONNECTIONS_OUT
Definition: clientmodel.h:36
@ CONNECTIONS_ALL
Definition: clientmodel.h:37
BlockSource
Definition: clientmodel.h:26
@ BLOCK_SOURCE_NETWORK
Definition: clientmodel.h:30
@ BLOCK_SOURCE_DISK
Definition: clientmodel.h:29
@ BLOCK_SOURCE_NONE
Definition: clientmodel.h:27
@ BLOCK_SOURCE_REINDEX
Definition: clientmodel.h:28