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