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
13 class AddressTableModel
;
17 class TransactionTableModel
;
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
46 explicit ClientModel(OptionsModel
*optionsModel
, QObject
*parent
= 0);
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
;
91 OptionsModel
*optionsModel
;
92 PeerTableModel
*peerTableModel
;
93 BanTableModel
*banTableModel
;
97 void subscribeToCoreSignals();
98 void unsubscribeFromCoreSignals();
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
);
116 void updateNumConnections(int numConnections
);
117 void updateNetworkActive(bool networkActive
);
119 void updateBanlist();
122 #endif // BITCOIN_QT_CLIENTMODEL_H