Remove unreachable or otherwise redundant code
[bitcoinplatinum.git] / src / qt / clientmodel.h
blob4c92e2144e32154b7683a4f3e9a29eeedd425a39
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 AddressTableModel;
14 class BanTableModel;
15 class OptionsModel;
16 class PeerTableModel;
17 class TransactionTableModel;
19 class CWallet;
20 class CBlockIndex;
22 QT_BEGIN_NAMESPACE
23 class QTimer;
24 QT_END_NAMESPACE
26 enum BlockSource {
27 BLOCK_SOURCE_NONE,
28 BLOCK_SOURCE_REINDEX,
29 BLOCK_SOURCE_DISK,
30 BLOCK_SOURCE_NETWORK
33 enum NumConnections {
34 CONNECTIONS_NONE = 0,
35 CONNECTIONS_IN = (1U << 0),
36 CONNECTIONS_OUT = (1U << 1),
37 CONNECTIONS_ALL = (CONNECTIONS_IN | CONNECTIONS_OUT),
40 /** Model for Bitcoin network client. */
41 class ClientModel : public QObject
43 Q_OBJECT
45 public:
46 explicit ClientModel(OptionsModel *optionsModel, QObject *parent = 0);
47 ~ClientModel();
49 OptionsModel *getOptionsModel();
50 PeerTableModel *getPeerTableModel();
51 BanTableModel *getBanTableModel();
53 //! Return number of connections, default is in- and outbound (total)
54 int getNumConnections(unsigned int flags = CONNECTIONS_ALL) const;
55 int getNumBlocks() const;
56 int getHeaderTipHeight() const;
57 int64_t getHeaderTipTime() const;
58 //! Return number of transactions in the mempool
59 long getMempoolSize() const;
60 //! Return the dynamic memory usage of the mempool
61 size_t getMempoolDynamicUsage() const;
63 quint64 getTotalBytesRecv() const;
64 quint64 getTotalBytesSent() const;
66 double getVerificationProgress(const CBlockIndex *tip) const;
67 QDateTime getLastBlockDate() const;
69 //! Return true if core is doing initial block download
70 bool inInitialBlockDownload() const;
71 //! Returns enum BlockSource of the current importing/syncing state
72 enum BlockSource getBlockSource() const;
73 //! Return true if network activity in core is enabled
74 bool getNetworkActive() const;
75 //! Toggle network activity state in core
76 void setNetworkActive(bool active);
77 //! Return warnings to be displayed in status bar
78 QString getStatusBarWarnings() const;
80 QString formatFullVersion() const;
81 QString formatSubVersion() const;
82 bool isReleaseVersion() const;
83 QString formatClientStartupTime() const;
84 QString dataDir() const;
86 // caches for the best header
87 mutable std::atomic<int> cachedBestHeaderHeight;
88 mutable std::atomic<int64_t> cachedBestHeaderTime;
90 private:
91 OptionsModel *optionsModel;
92 PeerTableModel *peerTableModel;
93 BanTableModel *banTableModel;
95 QTimer *pollTimer;
97 void subscribeToCoreSignals();
98 void unsubscribeFromCoreSignals();
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);
108 //! Fired when a message should be reported to the user
109 void message(const QString &title, const QString &message, unsigned int style);
111 // Show progress dialog e.g. for verifychain
112 void showProgress(const QString &title, int nProgress);
114 public Q_SLOTS:
115 void updateTimer();
116 void updateNumConnections(int numConnections);
117 void updateNetworkActive(bool networkActive);
118 void updateAlert();
119 void updateBanlist();
122 #endif // BITCOIN_QT_CLIENTMODEL_H