Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

clientmodel.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2015 The Bitcoin Core developers
2 // Copyright (c) 2014-2019 The Dash 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 BITCOIN_QT_CLIENTMODEL_H
7 #define BITCOIN_QT_CLIENTMODEL_H
8 
9 #include <evo/deterministicmns.h>
10 #include <sync.h>
11 
12 #include <QObject>
13 #include <QDateTime>
14 
15 #include <atomic>
16 
17 class BanTableModel;
18 class OptionsModel;
19 class PeerTableModel;
20 
21 class CBlockIndex;
22 
23 QT_BEGIN_NAMESPACE
24 class QTimer;
25 QT_END_NAMESPACE
26 
32 };
33 
36  CONNECTIONS_IN = (1U << 0),
37  CONNECTIONS_OUT = (1U << 1),
39 };
40 
42 class ClientModel : public QObject
43 {
44  Q_OBJECT
45 
46 public:
47  explicit ClientModel(OptionsModel *optionsModel, QObject *parent = 0);
48  ~ClientModel();
49 
53 
55  int getNumConnections(unsigned int flags = CONNECTIONS_ALL) const;
56  int getNumBlocks() const;
57  int getHeaderTipHeight() const;
58  int64_t getHeaderTipTime() const;
60  long getMempoolSize() const;
62  size_t getMempoolDynamicUsage() const;
64  size_t getInstantSentLockCount() const;
65 
66  void setMasternodeList(const CDeterministicMNList& mnList);
68  void refreshMasternodeList();
69 
70  quint64 getTotalBytesRecv() const;
71  quint64 getTotalBytesSent() const;
72 
73  double getVerificationProgress(const CBlockIndex *tip) const;
74  QDateTime getLastBlockDate() const;
75  QString getLastBlockHash() const;
76 
78  bool inInitialBlockDownload() const;
80  enum BlockSource getBlockSource() const;
82  bool getNetworkActive() const;
84  void setNetworkActive(bool active);
86  QString getStatusBarWarnings() const;
87 
88  QString formatFullVersion() const;
89  QString formatSubVersion() const;
90  bool isReleaseVersion() const;
91  QString formatClientStartupTime() const;
92  QString dataDir() const;
93 
94  // caches for the best header
95  mutable std::atomic<int> cachedBestHeaderHeight;
96  mutable std::atomic<int64_t> cachedBestHeaderTime;
97 
98 private:
102 
103  QTimer *pollTimer;
104 
105  // The cache for mn list is not technically needed because CDeterministicMNManager
106  // caches it internally for recent blocks but it's not enough to get consistent
107  // representation of the list in UI during initial sync/reindex, so we cache it here too.
108  mutable CCriticalSection cs_mnlinst; // protects mnListCached
110 
111  void subscribeToCoreSignals();
113 
114 Q_SIGNALS:
115  void numConnectionsChanged(int count);
116  void masternodeListChanged() const;
117  void numBlocksChanged(int count, const QDateTime& blockDate, const QString& blockHash, double nVerificationProgress, bool header);
118  void additionalDataSyncProgressChanged(double nSyncProgress);
119  void mempoolSizeChanged(long count, size_t mempoolSizeInBytes);
120  void islockCountChanged(size_t count);
121  void networkActiveChanged(bool networkActive);
122  void alertsChanged(const QString &warnings);
123 
125  void message(const QString &title, const QString &message, unsigned int style);
126 
127  // Show progress dialog e.g. for verifychain
128  void showProgress(const QString &title, int nProgress);
129 
130 public Q_SLOTS:
131  void updateTimer();
132  void updateNumConnections(int numConnections);
133  void updateNetworkActive(bool networkActive);
134  void updateAlert();
135  void updateBanlist();
136 };
137 
138 #endif // BITCOIN_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:100
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:96
void updateBanlist()
void setMasternodeList(const CDeterministicMNList &mnList)
Definition: clientmodel.cpp:78
void networkActiveChanged(bool networkActive)
BanTableModel * banTableModel
Definition: clientmodel.h:101
int flags
Definition: dash-tx.cpp:462
OptionsModel * getOptionsModel()
size_t getInstantSentLockCount() const
Return number of ISLOCKs.
quint64 getTotalBytesSent() const
std::atomic< int > cachedBestHeaderHeight
Definition: clientmodel.h:95
PeerTableModel * getPeerTableModel()
void masternodeListChanged() const
void numConnectionsChanged(int count)
QString getStatusBarWarnings() const
Return warnings to be displayed in status bar.
void alertsChanged(const QString &warnings)
int getNumConnections(unsigned int flags=CONNECTIONS_ALL) const
Return number of connections, default is in- and outbound (total)
Definition: clientmodel.cpp:62
double getVerificationProgress(const CBlockIndex *tip) const
enum BlockSource getBlockSource() const
Returns enum BlockSource of the current importing/syncing state.
NumConnections
Definition: clientmodel.h:34
Qt model providing information about connected peers, similar to the "getpeerinfo" RPC call...
quint64 getTotalBytesRecv() const
BlockSource
Definition: clientmodel.h:27
QString getLastBlockHash() const
void unsubscribeFromCoreSignals()
BanTableModel * getBanTableModel()
void subscribeToCoreSignals()
CDeterministicMNList mnListCached
Definition: clientmodel.h:109
CDeterministicMNList getMasternodeList() const
Definition: clientmodel.cpp:88
void islockCountChanged(size_t count)
void refreshMasternodeList()
Definition: clientmodel.cpp:94
CCriticalSection cs_mnlinst
Definition: clientmodel.h:108
Model for Dash network client.
Definition: clientmodel.h:42
QTimer * pollTimer
Definition: clientmodel.h:103
size_t getMempoolDynamicUsage() const
Return the dynamic memory usage of the mempool.
void numBlocksChanged(int count, const QDateTime &blockDate, const QString &blockHash, double nVerificationProgress, bool header)
QDateTime getLastBlockDate() const
void updateAlert()
ClientModel(OptionsModel *optionsModel, QObject *parent=0)
Definition: clientmodel.cpp:39
Interface from Qt to configuration data structure for Bitcoin client.
Definition: optionsmodel.h:25
The block chain is a tree shaped structure starting with the genesis block at the root...
Definition: chain.h:170
void additionalDataSyncProgressChanged(double nSyncProgress)
void updateTimer()
Qt model providing information about connected peers, similar to the "getpeerinfo" RPC call...
Definition: bantablemodel.h:39
static int count
Definition: tests.c:45
OptionsModel * optionsModel
Definition: clientmodel.h:99
void mempoolSizeChanged(long count, size_t mempoolSizeInBytes)
void setNetworkActive(bool active)
Toggle network activity state in core.
QString dataDir() const
int getNumBlocks() const
void updateNumConnections(int numConnections)
int getHeaderTipHeight() const
int64_t getHeaderTipTime() const
void showProgress(const QString &title, int nProgress)
Wrapped mutex: supports recursive locking, but no waiting TODO: We should move away from using the re...
Definition: sync.h:94
QString formatFullVersion() const
Released under the MIT license