BSHA3  0.17.99
P2P Blockchain, based on Bitcoin
clientmodel.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2018 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 BITCOIN_QT_CLIENTMODEL_H
6 #define BITCOIN_QT_CLIENTMODEL_H
7 
8 #include <QObject>
9 #include <QDateTime>
10 
11 #include <atomic>
12 #include <memory>
13 
14 class BanTableModel;
15 class OptionsModel;
16 class PeerTableModel;
17 
18 class CBlockIndex;
19 
20 namespace interfaces {
21 class Handler;
22 class Node;
23 }
24 
25 QT_BEGIN_NAMESPACE
26 class QTimer;
27 QT_END_NAMESPACE
28 
29 enum class BlockSource {
30  NONE,
31  REINDEX,
32  DISK,
33  NETWORK
34 };
35 
38  CONNECTIONS_IN = (1U << 0),
39  CONNECTIONS_OUT = (1U << 1),
41 };
42 
44 class ClientModel : public QObject
45 {
46  Q_OBJECT
47 
48 public:
49  explicit ClientModel(interfaces::Node& node, OptionsModel *optionsModel, QObject *parent = 0);
50  ~ClientModel();
51 
52  interfaces::Node& node() const { return m_node; }
56 
58  int getNumConnections(unsigned int flags = CONNECTIONS_ALL) const;
59  int getHeaderTipHeight() const;
60  int64_t getHeaderTipTime() const;
61 
63  enum BlockSource getBlockSource() const;
65  QString getStatusBarWarnings() const;
66 
67  QString formatFullVersion() const;
68  QString formatSubVersion() const;
69  bool isReleaseVersion() const;
70  QString formatClientStartupTime() const;
71  QString dataDir() const;
72  QString blocksDir() const;
73 
74  bool getProxyInfo(std::string& ip_port) const;
75 
76  // caches for the best header
77  mutable std::atomic<int> cachedBestHeaderHeight;
78  mutable std::atomic<int64_t> cachedBestHeaderTime;
79 
80 private:
82  std::unique_ptr<interfaces::Handler> m_handler_show_progress;
83  std::unique_ptr<interfaces::Handler> m_handler_notify_num_connections_changed;
84  std::unique_ptr<interfaces::Handler> m_handler_notify_network_active_changed;
85  std::unique_ptr<interfaces::Handler> m_handler_notify_alert_changed;
86  std::unique_ptr<interfaces::Handler> m_handler_banned_list_changed;
87  std::unique_ptr<interfaces::Handler> m_handler_notify_block_tip;
88  std::unique_ptr<interfaces::Handler> m_handler_notify_header_tip;
92 
93  QTimer *pollTimer;
94 
97 
98 Q_SIGNALS:
99  void numConnectionsChanged(int count);
100  void numBlocksChanged(int count, const QDateTime& blockDate, double nVerificationProgress, bool header);
101  void mempoolSizeChanged(long count, size_t mempoolSizeInBytes);
102  void networkActiveChanged(bool networkActive);
103  void alertsChanged(const QString &warnings);
104  void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut);
105 
107  void message(const QString &title, const QString &message, unsigned int style);
108 
109  // Show progress dialog e.g. for verifychain
110  void showProgress(const QString &title, int nProgress);
111 
112 public Q_SLOTS:
113  void updateTimer();
114  void updateNumConnections(int numConnections);
115  void updateNetworkActive(bool networkActive);
116  void updateAlert();
117  void updateBanlist();
118 };
119 
120 #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:90
void updateNetworkActive(bool networkActive)
QString formatSubVersion() const
interfaces::Node & m_node
Definition: clientmodel.h:81
bool isReleaseVersion() const
std::atomic< int64_t > cachedBestHeaderTime
Definition: clientmodel.h:78
void updateBanlist()
QString blocksDir() const
void networkActiveChanged(bool networkActive)
BanTableModel * banTableModel
Definition: clientmodel.h:91
std::unique_ptr< interfaces::Handler > m_handler_show_progress
Definition: clientmodel.h:82
OptionsModel * getOptionsModel()
std::atomic< int > cachedBestHeaderHeight
Definition: clientmodel.h:77
PeerTableModel * getPeerTableModel()
void numConnectionsChanged(int count)
QString getStatusBarWarnings() const
Return warnings to be displayed in status bar.
void alertsChanged(const QString &warnings)
std::unique_ptr< interfaces::Handler > m_handler_notify_block_tip
Definition: clientmodel.h:87
void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut)
int getNumConnections(unsigned int flags=CONNECTIONS_ALL) const
Return number of connections, default is in- and outbound (total)
Definition: clientmodel.cpp:58
enum BlockSource getBlockSource() const
Returns enum BlockSource of the current importing/syncing state.
NumConnections
Definition: clientmodel.h:36
Qt model providing information about connected peers, similar to the "getpeerinfo" RPC call...
BlockSource
Definition: clientmodel.h:29
void unsubscribeFromCoreSignals()
BanTableModel * getBanTableModel()
interfaces::Node & node() const
Definition: clientmodel.h:52
void subscribeToCoreSignals()
std::unique_ptr< interfaces::Handler > m_handler_banned_list_changed
Definition: clientmodel.h:86
ClientModel(interfaces::Node &node, OptionsModel *optionsModel, QObject *parent=0)
Definition: clientmodel.cpp:34
void numBlocksChanged(int count, const QDateTime &blockDate, double nVerificationProgress, bool header)
Model for Bitcoin network client.
Definition: clientmodel.h:44
std::unique_ptr< interfaces::Handler > m_handler_notify_header_tip
Definition: clientmodel.h:88
QTimer * pollTimer
Definition: clientmodel.h:93
void updateAlert()
std::unique_ptr< interfaces::Handler > m_handler_notify_num_connections_changed
Definition: clientmodel.h:83
Interface from Qt to configuration data structure for Bitcoin client.
Definition: optionsmodel.h:29
The block chain is a tree shaped structure starting with the genesis block at the root...
Definition: chain.h:170
void updateTimer()
Qt model providing information about connected peers, similar to the "getpeerinfo" RPC call...
Definition: bantablemodel.h:43
OptionsModel * optionsModel
Definition: clientmodel.h:89
void mempoolSizeChanged(long count, size_t mempoolSizeInBytes)
int flags
Definition: bsha3-tx.cpp:509
QString dataDir() const
std::unique_ptr< interfaces::Handler > m_handler_notify_network_active_changed
Definition: clientmodel.h:84
void updateNumConnections(int numConnections)
int getHeaderTipHeight() const
Definition: clientmodel.cpp:72
std::unique_ptr< interfaces::Handler > m_handler_notify_alert_changed
Definition: clientmodel.h:85
int64_t getHeaderTipTime() const
Definition: clientmodel.cpp:87
Top-level interface for a bitcoin node (bsha3d process).
Definition: node.h:35
void showProgress(const QString &title, int nProgress)
QString formatFullVersion() const
bool getProxyInfo(std::string &ip_port) const