Fabcoin Core  0.16.2
P2P Digital Currency
clientmodel.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2017 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 FABCOIN_QT_CLIENTMODEL_H
6 #define FABCOIN_QT_CLIENTMODEL_H
7 
8 #include <QObject>
9 #include <QDateTime>
10 
11 #include <atomic>
12 
13 class BanTableModel;
14 class OptionsModel;
15 class PeerTableModel;
16 
17 class CBlockIndex;
18 
19 QT_BEGIN_NAMESPACE
20 class QTimer;
21 QT_END_NAMESPACE
22 
28 };
29 
32  CONNECTIONS_IN = (1U << 0),
33  CONNECTIONS_OUT = (1U << 1),
35 };
36 
38 class ClientModel : public QObject
39 {
40  Q_OBJECT
41 
42 public:
43  explicit ClientModel(OptionsModel *optionsModel, QObject *parent = 0);
44  ~ClientModel();
45 
49 
51  int getNumConnections(unsigned int flags = CONNECTIONS_ALL) const;
52  int getNumBlocks() const;
53  int getHeaderTipHeight() const;
54  int64_t getHeaderTipTime() const;
56  long getMempoolSize() const;
58  size_t getMempoolDynamicUsage() const;
59 
60  quint64 getTotalBytesRecv() const;
61  quint64 getTotalBytesSent() const;
62 
63  double getVerificationProgress(const CBlockIndex *tip) const;
64  QDateTime getLastBlockDate() const;
65 
67  bool inInitialBlockDownload() const;
69  enum BlockSource getBlockSource() const;
71  bool getNetworkActive() const;
73  void setNetworkActive(bool active);
75  QString getStatusBarWarnings() const;
77  void getGasInfo(uint64_t& blockGasLimit, uint64_t& minGasPrice, uint64_t& nGasPrice) const;
78 
79  QString formatFullVersion() const;
80  QString formatSubVersion() const;
81  bool isReleaseVersion() const;
82  QString formatClientStartupTime() const;
83  QString dataDir() const;
84 
85  // caches for the best header
86  mutable std::atomic<int> cachedBestHeaderHeight;
87  mutable std::atomic<int64_t> cachedBestHeaderTime;
88 
89 private:
93 
94  QTimer *pollTimer;
95 
98 
99 Q_SIGNALS:
100  void numConnectionsChanged(int count);
101  void numBlocksChanged(int count, const QDateTime& blockDate, double nVerificationProgress, bool header);
102  void mempoolSizeChanged(long count, size_t mempoolSizeInBytes);
103  void networkActiveChanged(bool networkActive);
104  void alertsChanged(const QString &warnings);
105  void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut);
106  void tipChanged();
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();
119  void updateBanlist();
120 };
121 
122 #endif // FABCOIN_QT_CLIENTMODEL_H
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:91
void updateNetworkActive(bool networkActive)
std::atomic< int64_t > cachedBestHeaderTime
Definition: clientmodel.h:87
void updateBanlist()
double getVerificationProgress(const CBlockIndex *tip) const
quint64 getTotalBytesRecv() const
size_t count
Definition: ExecStats.cpp:37
bool getNetworkActive() const
Return true if network activity in core is enabled.
int getNumConnections(unsigned int flags=CONNECTIONS_ALL) const
Return number of connections, default is in- and outbound (total)
Definition: clientmodel.cpp:57
void networkActiveChanged(bool networkActive)
BanTableModel * banTableModel
Definition: clientmodel.h:92
OptionsModel * getOptionsModel()
std::atomic< int > cachedBestHeaderHeight
Definition: clientmodel.h:86
QString formatClientStartupTime() const
PeerTableModel * getPeerTableModel()
size_t getMempoolDynamicUsage() const
Return the dynamic memory usage of the mempool.
QString getStatusBarWarnings() const
Return warnings to be displayed in status bar.
void numConnectionsChanged(int count)
bool isReleaseVersion() const
void alertsChanged(const QString &warnings)
QString dataDir() const
void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut)
bool inInitialBlockDownload() const
Return true if core is doing initial block download.
NumConnections
Definition: clientmodel.h:30
Qt model providing information about connected peers, similar to the "getpeerinfo" RPC call...
QDateTime getLastBlockDate() const
BlockSource
Definition: clientmodel.h:23
void unsubscribeFromCoreSignals()
QString formatSubVersion() const
BanTableModel * getBanTableModel()
void subscribeToCoreSignals()
int getHeaderTipHeight() const
Definition: clientmodel.cpp:79
void numBlocksChanged(int count, const QDateTime &blockDate, double nVerificationProgress, bool header)
Model for Fabcoin network client.
Definition: clientmodel.h:38
QTimer * pollTimer
Definition: clientmodel.h:94
int getNumBlocks() const
Definition: clientmodel.cpp:73
quint64 getTotalBytesSent() const
void updateAlert()
ClientModel(OptionsModel *optionsModel, QObject *parent=0)
Definition: clientmodel.cpp:34
Interface from Qt to configuration data structure for Fabcoin client.
Definition: optionsmodel.h:22
The block chain is a tree shaped structure starting with the genesis block at the root...
Definition: chain.h:177
void updateTimer()
Qt model providing information about connected peers, similar to the "getpeerinfo" RPC call...
Definition: bantablemodel.h:37
int64_t getHeaderTipTime() const
Definition: clientmodel.cpp:93
OptionsModel * optionsModel
Definition: clientmodel.h:90
void mempoolSizeChanged(long count, size_t mempoolSizeInBytes)
void setNetworkActive(bool active)
Toggle network activity state in core.
void updateNumConnections(int numConnections)
long getMempoolSize() const
Return number of transactions in the mempool.
QString formatFullVersion() const
void showProgress(const QString &title, int nProgress)
enum BlockSource getBlockSource() const
Returns enum BlockSource of the current importing/syncing state.
void getGasInfo(uint64_t &blockGasLimit, uint64_t &minGasPrice, uint64_t &nGasPrice) const
Get the information about the needed gas.