Skip to content

Commit

Permalink
Merge #930: [UI] IPv4, IPv6 and TOR stats added to Information tab
Browse files Browse the repository at this point in the history
d07ca0c [UI] IPV4, IPv6 and TOR stats added to Information tab

aaa320e [UI] IPv4, IPv6 and TOR stats added to Information tab
  • Loading branch information
crowning- authored and schinzelh committed Aug 6, 2016
1 parent 5a8c0c9 commit 072fd72
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
34 changes: 34 additions & 0 deletions src/masternodeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,40 @@ int CMasternodeMan::CountEnabled(int protocolVersion)
return i;
}

int CMasternodeMan::CountByIP(int nodeType)
{
int nIPv4_nodes = 0;
int nIPv6_nodes = 0;
int nTOR_nodes = 0;

BOOST_FOREACH(CMasternode& mn, vMasternodes) {
if(mn.addr.IsIPv6()){
nIPv6_nodes++;
} else if(mn.addr.IsTor()){
nTOR_nodes++;
}
else{
nIPv4_nodes++; // Must be IPv4 if it isn't IPv6 or TOR
}
}

switch(nodeType)
{
case NET_IPV4:
return nIPv4_nodes;

case NET_IPV6:
return nIPv6_nodes;

case NET_TOR:
return nTOR_nodes;

default:
return nIPv4_nodes + nIPv6_nodes + nTOR_nodes; // Default: return all nodes
}

}

void CMasternodeMan::DsegUpdate(CNode* pnode)
{
LOCK(cs);
Expand Down
2 changes: 2 additions & 0 deletions src/masternodeman.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ class CMasternodeMan
void Clear();

int CountEnabled(int protocolVersion = -1);

int CountByIP(int nodeType);

void DsegUpdate(CNode* pnode);

Expand Down
7 changes: 5 additions & 2 deletions src/qt/clientmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,12 @@ int ClientModel::getNumConnections(unsigned int flags) const

QString ClientModel::getMasternodeCountString() const
{
return tr("Total: %1 (PS compatible: %2 / Enabled: %3)").arg(QString::number((int)mnodeman.size()))
return tr("Total: %1 (PS compatible: %2 / Enabled: %3) (IPv4: %4, IPv6: %5, TOR: %6)").arg(QString::number((int)mnodeman.size()))
.arg(QString::number((int)mnodeman.CountEnabled(MIN_PRIVATESEND_PEER_PROTO_VERSION)))
.arg(QString::number((int)mnodeman.CountEnabled()));
.arg(QString::number((int)mnodeman.CountEnabled()))
.arg(QString::number((int)mnodeman.CountByIP(NET_IPV4)))
.arg(QString::number((int)mnodeman.CountByIP(NET_IPV6)))
.arg(QString::number((int)mnodeman.CountByIP(NET_TOR)));
}

int ClientModel::getNumBlocks() const
Expand Down

0 comments on commit 072fd72

Please sign in to comment.