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(); });
136 if (m_cached_tip_blocks.IsNull()) {
137 m_cached_tip_blocks = tip;
139 return m_cached_tip_blocks;
177 return CLIENT_VERSION_IS_RELEASE;
194 double verification_progress,
SyncType synctype)
198 cachedBestHeaderHeight = tip.block_height;
199 cachedBestHeaderTime = tip.block_time;
201 m_cached_num_blocks = tip.block_height;
202 WITH_LOCK(m_cached_tip_mutex, m_cached_tip_blocks = tip.block_hash;);
218 Q_EMIT numBlocksChanged(tip.block_height,
219 QDateTime::fromSecsSinceEpoch(tip.block_time),
220 verification_progress, synctype, sync_state);
221 nLastUpdateNotification = now;
226 [
this](
const std::string &title,
int progress,
227 [[maybe_unused]]
bool resume_possible) {
228 Q_EMIT showProgress(QString::fromStdString(title), progress);
231 [
this](
int new_num_connections) {
232 Q_EMIT numConnectionsChanged(new_num_connections);
236 Q_EMIT networkActiveChanged(network_active);
239 qDebug() <<
"ClientModel: NotifyAlertChanged";
240 Q_EMIT alertsChanged(getStatusBarWarnings());
243 qDebug() <<
"ClienModel: Requesting update for peer banlist";
244 QMetaObject::invokeMethod(banTableModel,
245 [this] { banTableModel->refresh(); });
247 m_event_handlers.emplace_back(
m_node.handleNotifyBlockTip(
249 double verification_progress) {
250 TipChanged(sync_state, tip, verification_progress,
251 SyncType::BLOCK_SYNC);
253 m_event_handlers.emplace_back(
m_node.handleNotifyHeaderTip(
256 TipChanged(sync_state, tip, 0.0,
257 presync ? SyncType::HEADER_PRESYNC
258 : SyncType::HEADER_SYNC);
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
void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut)
QString blocksDir() const
QString getStatusBarWarnings() const
Return warnings to be displayed in status bar.
std::vector< std::unique_ptr< interfaces::Handler > > m_event_handlers
int getHeaderTipHeight() const
std::atomic< int64_t > cachedBestHeaderTime
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)
BlockSource getBlockSource() const
Returns the block source of the current importing/syncing state.
int64_t getHeaderTipTime() const
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)
OptionsModel * optionsModel
BanTableModel * banTableModel
QThread *const m_thread
A thread to interact with m_node asynchronously.
BanTableModel * getBanTableModel()
void unsubscribeFromCoreSignals()
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()
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 > handleNotifyAlertChanged(NotifyAlertChangedFn 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.