16 #include "validation.h"
27 #include <boost/bind/bind.hpp>
31 static const int64_t nClientStartupTime =
GetTime();
32 static int64_t nLastHeaderTipUpdateNotification = 0;
33 static int64_t nLastBlockTipUpdateNotification = 0;
37 optionsModel(_optionsModel),
70 return g_connman->GetNodeCount(connections);
175 hash_256.
SetHex(hash.toStdString());
255 return QDateTime::fromTime_t(nClientStartupTime).toString();
269 static void ShowProgress(
ClientModel *clientmodel,
const std::string &title,
int nProgress)
272 QMetaObject::invokeMethod(clientmodel,
"showProgress", Qt::QueuedConnection,
273 Q_ARG(QString, QString::fromStdString(title)),
274 Q_ARG(
int, nProgress));
277 static void NotifyNumConnectionsChanged(
ClientModel *clientmodel,
int newNumConnections)
280 QMetaObject::invokeMethod(clientmodel,
"updateNumConnections", Qt::QueuedConnection,
281 Q_ARG(
int, newNumConnections));
284 static void NotifyNetworkActiveChanged(
ClientModel *clientmodel,
bool networkActive)
286 QMetaObject::invokeMethod(clientmodel,
"updateNetworkActive", Qt::QueuedConnection,
287 Q_ARG(
bool, networkActive));
292 qDebug() <<
"NotifyAlertChanged: " + QString::fromStdString(hash.
GetHex()) +
" status=" + QString::number(status);
293 QMetaObject::invokeMethod(clientmodel,
"updateAlert", Qt::QueuedConnection,
294 Q_ARG(QString, QString::fromStdString(hash.
GetHex())),
298 static void BannedListChanged(
ClientModel *clientmodel)
300 qDebug() << QString(
"%1: Requesting update for peer banlist").arg(__func__);
301 QMetaObject::invokeMethod(clientmodel,
"updateBanlist", Qt::QueuedConnection);
304 static void BlockTipChanged(
ClientModel *clientmodel,
bool initialSync,
const CBlockIndex *pIndex,
bool fHeader)
313 int64_t& nLastUpdateNotification = fHeader ? nLastHeaderTipUpdateNotification : nLastBlockTipUpdateNotification;
321 if (!initialSync || now - nLastUpdateNotification > MODEL_UPDATE_DELAY) {
323 QMetaObject::invokeMethod(clientmodel,
"numBlocksChanged", Qt::QueuedConnection,
325 Q_ARG(QDateTime, QDateTime::fromTime_t(pIndex->
GetBlockTime())),
327 Q_ARG(
bool, fHeader));
328 nLastUpdateNotification = now;
336 boost::placeholders::_1,
337 boost::placeholders::_2));
339 boost::placeholders::_1));
341 boost::placeholders::_1));
343 boost::placeholders::_1,
344 boost::placeholders::_2));
347 boost::placeholders::_1,
348 boost::placeholders::_2,
false));
350 boost::placeholders::_1,
351 boost::placeholders::_2,
true));
358 boost::placeholders::_1,
359 boost::placeholders::_2));
361 boost::placeholders::_1));
363 boost::placeholders::_1));
365 boost::placeholders::_1,
366 boost::placeholders::_2));
369 boost::placeholders::_1,
370 boost::placeholders::_2,
false));
372 boost::placeholders::_1,
373 boost::placeholders::_2,
true));
const CChainParams & Params()
Return the currently selected parameters.
Qt model providing information about connected peers, similar to the "getpeerinfo" RPC call.
An alert is a combination of a serialized CUnsignedAlert and a signature.
static CAlert getAlertByHash(const uint256 &hash)
The block chain is a tree shaped structure starting with the genesis block at the root,...
int64_t GetBlockTime() const
int nHeight
height of the entry in the chain. The genesis block has height 0
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or NULL if none.
int Height() const
Return the maximal height in the chain.
boost::signals2::signal< void(const uint256 &hash, ChangeType status)> NotifyAlertChanged
New, updated or cancelled alert.
boost::signals2::signal< void(bool, const CBlockIndex *)> NotifyBlockTip
New block has been accepted.
boost::signals2::signal< void(int newNumConnections)> NotifyNumConnectionsChanged
Number of network connections changed.
boost::signals2::signal< void(const std::string &title, int nProgress)> ShowProgress
Show progress e.g.
boost::signals2::signal< void(bool, const CBlockIndex *)> NotifyHeaderTip
Best header has changed.
boost::signals2::signal< void(void)> BannedListChanged
Banlist did change.
boost::signals2::signal< void(bool networkActive)> NotifyNetworkActiveChanged
Network activity state changed.
size_t DynamicMemoryUsage() const
Model for Bitcoin network client.
void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut)
void setNetworkActive(bool active)
Toggle network activity state in core.
QString getStatusBarWarnings() const
Return warnings to be displayed in status bar.
void updateAlert(const QString &hash, int status)
int getHeaderTipHeight() const
std::atomic< int64_t > cachedBestHeaderTime
quint64 getTotalBytesRecv() const
quint64 getTotalBytesSent() const
PeerTableModel * getPeerTableModel()
void updateNetworkActive(bool networkActive)
std::atomic< int > cachedBestHeaderHeight
void updateNumConnections(int numConnections)
size_t getMempoolDynamicUsage() const
Return the dynamic memory usage of the mempool.
void message(const QString &title, const QString &message, unsigned int style)
Fired when a message should be reported to the user.
QDateTime getLastBlockDate() const
void numConnectionsChanged(int count)
int64_t getHeaderTipTime() const
double getVerificationProgress(const CBlockIndex *tip) const
bool getNetworkActive() const
Return true if network activity in core is enabled.
QString formatClientStartupTime() const
int getNumConnections(unsigned int flags=CONNECTIONS_ALL) const
Return number of connections, default is in- and outbound (total)
enum BlockSource getBlockSource() const
Returns enum BlockSource of the current importing/syncing state.
OptionsModel * optionsModel
BanTableModel * banTableModel
BanTableModel * getBanTableModel()
void unsubscribeFromCoreSignals()
long getMempoolSize() const
Return number of transactions in the mempool.
void alertsChanged(const QString &warnings)
OptionsModel * getOptionsModel()
QString formatFullVersion() const
PeerTableModel * peerTableModel
ClientModel(OptionsModel *optionsModel, QObject *parent=0)
QString formatSubVersion() const
void mempoolSizeChanged(long count, size_t mempoolSizeInBytes)
bool isReleaseVersion() const
bool inInitialBlockDownload() const
Return true if core is doing initial block download.
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.
void SetHex(const char *psz)
std::string GetHex() const
std::string FormatFullVersion()
#define CLIENT_VERSION_IS_RELEASE
Set to true for release, false for prerelease or test build.
std::unique_ptr< CConnman > g_connman
QString boostPathToQString(const boost::filesystem::path &path)
std::string strSubVersion
Subversion as sent to the P2P network in version messages.
CClientUIInterface uiInterface
ChangeType
General change type (added, updated, removed).
const boost::filesystem::path & GetDataDir(bool fNetSpecific)
int64_t GetTime()
GetTimeMicros() and GetTimeMillis() both return the system time, but in different units.
CCriticalSection cs_main
Global state.
CTxMemPool mempool(::minRelayTxFee)
bool IsInitialBlockDownload()
Check whether we are doing an initial block download (synchronizing from disk or network)
CBlockIndex * pindexBestHeader
Best header we've seen so far (used for getheaders queries' starting points).
CChain chainActive
The currently-connected chain of blocks (protected by cs_main).
double GuessVerificationProgress(const ChainTxData &data, CBlockIndex *pindex)
Guess how far we are in the verification process at the given block index.
std::atomic_bool fImporting
std::string GetWarnings(const std::string &strFor)
Format a string that describes several potential problems detected by the core.