Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UI] IPv4, IPv6 and TOR stats added to Information tab #930

Merged
merged 2 commits into from
Aug 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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