X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fqt%2Fclientmodel.cpp;h=45fc8bec109065c4c748f57f9db93af1c6f41813;hb=e0e4beec1d93de51c01b180993372498688e330e;hp=c100188021297198b39882cb3b756a8ee3cafabc;hpb=dfb7a23711b260ff9232f9d878b82804eac19c4c;p=novacoin.git diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index c100188..45fc8be 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -6,7 +6,7 @@ #include "alert.h" #include "main.h" -#include "ui_interface.h" +#include "interface.h" #include #include @@ -14,7 +14,7 @@ extern double GetPoSKernelPS(); extern double GetDifficulty(const CBlockIndex* blockindex); -static const int64 nClientStartupTime = GetTime(); +static const int64_t nClientStartupTime = GetTime(); ClientModel::ClientModel(OptionsModel *optionsModel, QObject *parent) : QObject(parent), optionsModel(optionsModel), @@ -48,9 +48,18 @@ double ClientModel::getDifficulty(bool fProofofStake) return GetDifficulty(GetLastBlockIndex(pindexBest,false)); } -int ClientModel::getNumConnections() const +int ClientModel::getNumConnections(uint8_t flags) const { - return vNodes.size(); + LOCK(cs_vNodes); + if (flags == CONNECTIONS_ALL) // Shortcut if we want total + return (int)(vNodes.size()); + + int nNum = 0; + BOOST_FOREACH(CNode* pnode, vNodes) + if (flags & (pnode->fInbound ? CONNECTIONS_IN : CONNECTIONS_OUT)) + nNum++; + + return nNum; } int ClientModel::getNumBlocks() const @@ -195,14 +204,14 @@ void ClientModel::subscribeToCoreSignals() { // Connect signals to client uiInterface.NotifyBlocksChanged.connect(boost::bind(NotifyBlocksChanged, this)); - uiInterface.NotifyNumConnectionsChanged.connect(boost::bind(NotifyNumConnectionsChanged, this, _1)); - uiInterface.NotifyAlertChanged.connect(boost::bind(NotifyAlertChanged, this, _1, _2)); + uiInterface.NotifyNumConnectionsChanged.connect(boost::bind(NotifyNumConnectionsChanged, this, boost::placeholders::_1)); + uiInterface.NotifyAlertChanged.connect(boost::bind(NotifyAlertChanged, this, boost::placeholders::_1, boost::placeholders::_2)); } void ClientModel::unsubscribeFromCoreSignals() { // Disconnect signals from client uiInterface.NotifyBlocksChanged.disconnect(boost::bind(NotifyBlocksChanged, this)); - uiInterface.NotifyNumConnectionsChanged.disconnect(boost::bind(NotifyNumConnectionsChanged, this, _1)); - uiInterface.NotifyAlertChanged.disconnect(boost::bind(NotifyAlertChanged, this, _1, _2)); + uiInterface.NotifyNumConnectionsChanged.disconnect(boost::bind(NotifyNumConnectionsChanged, this, boost::placeholders::_1)); + uiInterface.NotifyAlertChanged.disconnect(boost::bind(NotifyAlertChanged, this, boost::placeholders::_1, boost::placeholders::_2)); }