Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
clientmodel.h
Go to the documentation of this file.
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.
4
5#ifndef BITCOIN_QT_CLIENTMODEL_H
6#define BITCOIN_QT_CLIENTMODEL_H
7
8#include <QDateTime>
9#include <QObject>
10
11#include <atomic>
12#include <memory>
14#include <sync.h>
15
16class BanTableModel;
17class CBlockIndex;
18class OptionsModel;
19class PeerTableModel;
20
21class CBlockIndex;
22enum class SynchronizationState;
23
24namespace interfaces {
25class Handler;
26class Node;
27struct BlockTip;
28} // namespace interfaces
29
31class QTimer;
33
34enum class BlockSource {
35 NONE,
36 DISK,
37 NETWORK,
38};
39
41
43class ClientModel : public QObject {
45
46public:
53
55 QObject *parent = nullptr);
57
58 interfaces::Node &node() const { return m_node; }
62
65 int getNumBlocks() const;
67 int getHeaderTipHeight() const;
69
74
77 bool isReleaseVersion() const;
79 QString dataDir() const;
80 QString blocksDir() const;
81
82 bool getProxyInfo(std::string &ip_port) const;
83
84 // caches for the best header: hash, number of blocks and block time
88
91
92private:
94 std::unique_ptr<interfaces::Handler> m_handler_show_progress;
95 std::unique_ptr<interfaces::Handler>
97 std::unique_ptr<interfaces::Handler>
99 std::unique_ptr<interfaces::Handler> m_handler_notify_alert_changed;
100 std::unique_ptr<interfaces::Handler> m_handler_banned_list_changed;
101 std::unique_ptr<interfaces::Handler> m_handler_notify_block_tip;
102 std::unique_ptr<interfaces::Handler> m_handler_notify_header_tip;
106
109
111 double verification_progress, SyncType synctype);
114
118 double nVerificationProgress, SyncType header,
124
126 void message(const QString &title, const QString &message,
127 unsigned int style);
128
129 // Show progress dialog e.g. for verifychain
130 void showProgress(const QString &title, int nProgress);
131};
132
133#endif // BITCOIN_QT_CLIENTMODEL_H
int flags
Qt model providing information about connected peers, similar to the "getpeerinfo" RPC call.
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition blockindex.h:25
Model for Bitcoin network client.
Definition clientmodel.h:43
std::unique_ptr< interfaces::Handler > m_handler_banned_list_changed
void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut)
void showProgress(const QString &title, int nProgress)
QString blocksDir() const
QString getStatusBarWarnings() const
Return warnings to be displayed in status bar.
int getHeaderTipHeight() const
std::unique_ptr< interfaces::Handler > m_handler_show_progress
Definition clientmodel.h:94
std::atomic< int64_t > cachedBestHeaderTime
Definition clientmodel.h:86
std::unique_ptr< interfaces::Handler > m_handler_notify_alert_changed
Definition clientmodel.h:99
interfaces::Node & m_node
Definition clientmodel.h:93
Mutex m_cached_tip_mutex
Definition clientmodel.h:89
PeerTableModel * getPeerTableModel()
BlockHash m_cached_tip_blocks GUARDED_BY(m_cached_tip_mutex)
std::atomic< int > cachedBestHeaderHeight
Definition clientmodel.h:85
BlockHash getBestBlockHash() EXCLUSIVE_LOCKS_REQUIRED(!m_cached_tip_mutex)
int getNumConnections(NumConnections flags=CONNECTIONS_ALL) const
Return number of connections, default is in- and outbound (total)
void message(const QString &title, const QString &message, unsigned int style)
Fired when a message should be reported to the user.
void numConnectionsChanged(int count)
BlockSource getBlockSource() const
Returns the block source of the current importing/syncing state.
int getNumBlocks() const
int64_t getHeaderTipTime() const
std::unique_ptr< interfaces::Handler > m_handler_notify_block_tip
QString formatClientStartupTime() const
void TipChanged(SynchronizationState sync_state, interfaces::BlockTip tip, double verification_progress, SyncType synctype)
std::unique_ptr< interfaces::Handler > m_handler_notify_num_connections_changed
Definition clientmodel.h:96
std::unique_ptr< interfaces::Handler > m_handler_notify_network_active_changed
Definition clientmodel.h:98
OptionsModel * optionsModel
BanTableModel * banTableModel
QThread *const m_thread
A thread to interact with m_node asynchronously.
std::unique_ptr< interfaces::Handler > m_handler_notify_header_tip
BanTableModel * getBanTableModel()
void unsubscribeFromCoreSignals()
void numBlocksChanged(int count, const QDateTime &blockDate, double nVerificationProgress, SyncType header, SynchronizationState sync_state)
void alertsChanged(const QString &warnings)
QString dataDir() const
std::atomic< int > m_cached_num_blocks
Definition clientmodel.h:87
OptionsModel * getOptionsModel()
QString formatFullVersion() const
PeerTableModel * peerTableModel
bool getProxyInfo(std::string &ip_port) const
QString formatSubVersion() const
void mempoolSizeChanged(long count, size_t mempoolSizeInBytes)
bool isReleaseVersion() const
void subscribeToCoreSignals()
void networkActiveChanged(bool networkActive)
interfaces::Node & node() const
Definition clientmodel.h:58
Interface from Qt to configuration data structure for Bitcoin client.
Qt model providing information about connected peers, similar to the "getpeerinfo" RPC call.
Top-level interface for a bitcoin node (bitcoind process).
Definition node.h:59
SyncType
Definition clientmodel.h:40
@ HEADER_PRESYNC
BlockSource
Definition clientmodel.h:34
Definition init.h:28
Implement std::hash so RCUPtr can be used as a key for maps or sets.
Definition rcu.h:259
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition random.h:85
A BlockHash is a unqiue identifier for a block.
Definition blockhash.h:13
Block tip (could be a header or not, depends on the subscribed signal).
Definition node.h:270
static int count
Definition tests.c:31
#define EXCLUSIVE_LOCKS_REQUIRED(...)
SynchronizationState
Current sync state passed to tip changed callbacks.
Definition validation.h:114