20#include <validation.h>
34 : QObject(parent),
m_node(
node), optionsModel(_optionsModel),
35 peerTableModel(nullptr), banTableModel(nullptr),
36 m_thread(new QThread(this)) {
42 QTimer *timer =
new QTimer;
44 connect(timer, &QTimer::timeout, [
this] {
52 connect(
m_thread, &QThread::finished, timer, &QObject::deleteLater);
53 connect(
m_thread, &QThread::started, [timer] { timer->start(); });
132 if (m_cached_tip_blocks.IsNull()) {
133 m_cached_tip_blocks = tip;
135 return m_cached_tip_blocks;
173 return CLIENT_VERSION_IS_RELEASE;
190 double verification_progress,
SyncType synctype)
194 cachedBestHeaderHeight = tip.block_height;
195 cachedBestHeaderTime = tip.block_time;
197 m_cached_num_blocks = tip.block_height;
198 WITH_LOCK(m_cached_tip_mutex, m_cached_tip_blocks = tip.block_hash;);
214 Q_EMIT numBlocksChanged(tip.block_height,
215 QDateTime::fromSecsSinceEpoch(tip.block_time),
216 verification_progress, synctype, sync_state);
217 nLastUpdateNotification = now;
222 [
this](
const std::string &title,
int progress,
223 [[maybe_unused]]
bool resume_possible) {
224 Q_EMIT
showProgress(QString::fromStdString(title), progress);
228 [
this](
int new_num_connections) {
236 qDebug() <<
"ClientModel: NotifyAlertChanged";
240 qDebug() <<
"ClienModel: Requesting update for peer banlist";
246 double verification_progress) {
247 TipChanged(sync_state, tip, verification_progress,
fs::path GetDataDirNet() const
Get data directory path with appended network identifier.
fs::path GetBlocksDirPath() const
Get blocks directory path.
Qt model providing information about connected peers, similar to the "getpeerinfo" RPC call.
std::string ToStringIPPort() const
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
std::atomic< int64_t > cachedBestHeaderTime
std::unique_ptr< interfaces::Handler > m_handler_notify_alert_changed
interfaces::Node & m_node
PeerTableModel * getPeerTableModel()
std::atomic< int > cachedBestHeaderHeight
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 numConnectionsChanged(int count)
BlockSource getBlockSource() const
Returns the block source of the current importing/syncing state.
int64_t getHeaderTipTime() const
std::unique_ptr< interfaces::Handler > m_handler_notify_block_tip
QString formatClientStartupTime() const
ClientModel(interfaces::Node &node, OptionsModel *optionsModel, QObject *parent=nullptr)
void TipChanged(SynchronizationState sync_state, interfaces::BlockTip tip, double verification_progress, SyncType synctype)
std::unique_ptr< interfaces::Handler > m_handler_notify_num_connections_changed
std::unique_ptr< interfaces::Handler > m_handler_notify_network_active_changed
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 alertsChanged(const QString &warnings)
std::atomic< int > m_cached_num_blocks
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)
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).
virtual std::unique_ptr< Handler > handleShowProgress(ShowProgressFn fn)=0
virtual bilingual_str getWarnings()=0
Get warnings.
virtual std::unique_ptr< Handler > handleNotifyBlockTip(NotifyBlockTipFn fn)=0
virtual std::unique_ptr< Handler > handleNotifyAlertChanged(NotifyAlertChangedFn fn)=0
virtual std::unique_ptr< Handler > handleNotifyHeaderTip(NotifyHeaderTipFn fn)=0
virtual bool getProxy(Network net, proxyType &proxy_info)=0
Get proxy.
virtual BlockHash getBestBlockHash()=0
Get best block hash.
virtual size_t getMempoolSize()=0
Get mempool size.
virtual bool isLoadingBlocks()=0
Is loading blocks.
virtual size_t getNodeCount(ConnectionDirection flags)=0
Get number of connections.
virtual bool getHeaderTip(int &height, int64_t &block_time)=0
Get header tip height and time.
virtual int64_t getTotalBytesRecv()=0
Get total bytes recv.
virtual std::unique_ptr< Handler > handleBannedListChanged(BannedListChangedFn fn)=0
virtual std::unique_ptr< Handler > handleNotifyNetworkActiveChanged(NotifyNetworkActiveChangedFn fn)=0
virtual int64_t getTotalBytesSent()=0
Get total bytes sent.
virtual size_t getMempoolDynamicUsage()=0
Get mempool dynamic usage.
virtual int getNumBlocks()=0
Get num blocks.
virtual std::unique_ptr< Handler > handleNotifyNumConnectionsChanged(NotifyNumConnectionsChangedFn fn)=0
static int64_t nLastHeaderTipUpdateNotification
static int64_t nLastBlockTipUpdateNotification
std::string FormatFullVersion()
const Config & GetConfig()
static const int MODEL_UPDATE_DELAY
QString boostPathToQString(const fs::path &path)
Convert OS specific boost path to QString through UTF-8.
void ThreadRename(std::string &&)
Rename a thread both in terms of an internal (in-memory) name as well as its system thread name.
std::string userAgent(const Config &config)
A BlockHash is a unqiue identifier for a block.
Block tip (could be a header or not, depends on the subscribed signal).
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
#define EXCLUSIVE_LOCKS_REQUIRED(...)
int64_t GetTimeMillis()
Returns the system time (not mockable)
SynchronizationState
Current sync state passed to tip changed callbacks.