[tests] Add -blocknotify functional test
[bitcoinplatinum.git] / src / qt / clientmodel.h
blob6447cae1bb4e03bc4a211a55181b6321a69129f0
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.
5 #ifndef BITCOIN_QT_CLIENTMODEL_H
6 #define BITCOIN_QT_CLIENTMODEL_H
8 #include <QObject>
9 #include <QDateTime>
11 #include <atomic>
13 class BanTableModel;
14 class OptionsModel;
15 class PeerTableModel;
17 class CBlockIndex;
19 QT_BEGIN_NAMESPACE
20 class QTimer;
21 QT_END_NAMESPACE
23 enum BlockSource {
24 BLOCK_SOURCE_NONE,
25 BLOCK_SOURCE_REINDEX,
26 BLOCK_SOURCE_DISK,
27 BLOCK_SOURCE_NETWORK
30 enum NumConnections {
31 CONNECTIONS_NONE = 0,
32 CONNECTIONS_IN = (1U << 0),
33 CONNECTIONS_OUT = (1U << 1),
34 CONNECTIONS_ALL = (CONNECTIONS_IN | CONNECTIONS_OUT),
37 /** Model for Bitcoin network client. */
38 class ClientModel : public QObject
40 Q_OBJECT
42 public:
43 explicit ClientModel(OptionsModel *optionsModel, QObject *parent = 0);
44 ~ClientModel();
46 OptionsModel *getOptionsModel();
47 PeerTableModel *getPeerTableModel();
48 BanTableModel *getBanTableModel();
50 //! Return number of connections, default is in- and outbound (total)
51 int getNumConnections(unsigned int flags = CONNECTIONS_ALL) const;
52 int getNumBlocks() const;
53 int getHeaderTipHeight() const;
54 int64_t getHeaderTipTime() const;
55 //! Return number of transactions in the mempool
56 long getMempoolSize() const;
57 //! Return the dynamic memory usage of the mempool
58 size_t getMempoolDynamicUsage() const;
60 quint64 getTotalBytesRecv() const;
61 quint64 getTotalBytesSent() const;
63 double getVerificationProgress(const CBlockIndex *tip) const;
64 QDateTime getLastBlockDate() const;
66 //! Return true if core is doing initial block download
67 bool inInitialBlockDownload() const;
68 //! Returns enum BlockSource of the current importing/syncing state
69 enum BlockSource getBlockSource() const;
70 //! Return true if network activity in core is enabled
71 bool getNetworkActive() const;
72 //! Toggle network activity state in core
73 void setNetworkActive(bool active);
74 //! Return warnings to be displayed in status bar
75 QString getStatusBarWarnings() const;
77 QString formatFullVersion() const;
78 QString formatSubVersion() const;
79 bool isReleaseVersion() const;
80 QString formatClientStartupTime() const;
81 QString dataDir() const;
83 // caches for the best header
84 mutable std::atomic<int> cachedBestHeaderHeight;
85 mutable std::atomic<int64_t> cachedBestHeaderTime;
87 private:
88 OptionsModel *optionsModel;
89 PeerTableModel *peerTableModel;
90 BanTableModel *banTableModel;
92 QTimer *pollTimer;
94 void subscribeToCoreSignals();
95 void unsubscribeFromCoreSignals();
97 Q_SIGNALS:
98 void numConnectionsChanged(int count);
99 void numBlocksChanged(int count, const QDateTime& blockDate, double nVerificationProgress, bool header);
100 void mempoolSizeChanged(long count, size_t mempoolSizeInBytes);
101 void networkActiveChanged(bool networkActive);
102 void alertsChanged(const QString &warnings);
103 void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut);
105 //! Fired when a message should be reported to the user
106 void message(const QString &title, const QString &message, unsigned int style);
108 // Show progress dialog e.g. for verifychain
109 void showProgress(const QString &title, int nProgress);
111 public Q_SLOTS:
112 void updateTimer();
113 void updateNumConnections(int numConnections);
114 void updateNetworkActive(bool networkActive);
115 void updateAlert();
116 void updateBanlist();
119 #endif // BITCOIN_QT_CLIENTMODEL_H