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

Add helpers GetSentinelString() and GetDaemonString() to CMasternodePing #2192

Merged
merged 1 commit into from
Jul 25, 2018
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
10 changes: 10 additions & 0 deletions src/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,16 @@ void CMasternodePing::Relay(CConnman& connman)
connman.RelayInv(inv);
}

std::string CMasternodePing::GetSentinelString() const
{
return nSentinelVersion > DEFAULT_SENTINEL_VERSION ? SafeIntVersionToString(nSentinelVersion) : "Unknown";
}

std::string CMasternodePing::GetDaemonString() const
{
return nDaemonVersion > DEFAULT_DAEMON_VERSION ? FormatVersion(nDaemonVersion) : "Unknown";
}

void CMasternode::AddGovernanceVote(uint256 nGovernanceObjectHash)
{
if(mapGovernanceObjectsVotedOn.count(nGovernanceObjectHash)) {
Expand Down
3 changes: 3 additions & 0 deletions src/masternode.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ class CMasternodePing
bool CheckAndUpdate(CMasternode* pmn, bool fFromNewBroadcast, int& nDos, CConnman& connman);
void Relay(CConnman& connman);

std::string GetSentinelString() const;
std::string GetDaemonString() const;

explicit operator bool() const;
};

Expand Down
12 changes: 6 additions & 6 deletions src/rpc/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,12 +557,12 @@ UniValue masternodelist(const JSONRPCRequest& request)
strOutpoint.find(strFilter) == std::string::npos) continue;
obj.push_back(Pair(strOutpoint, strAddress));
} else if (strMode == "daemon") {
std::string strDaemon = mn.lastPing.nDaemonVersion > DEFAULT_DAEMON_VERSION ? FormatVersion(mn.lastPing.nDaemonVersion) : "Unknown";
std::string strDaemon = mn.lastPing.GetDaemonString();
if (strFilter !="" && strDaemon.find(strFilter) == std::string::npos &&
strOutpoint.find(strFilter) == std::string::npos) continue;
obj.push_back(Pair(strOutpoint, strDaemon));
} else if (strMode == "sentinel") {
std::string strSentinel = mn.lastPing.nSentinelVersion > DEFAULT_SENTINEL_VERSION ? SafeIntVersionToString(mn.lastPing.nSentinelVersion) : "Unknown";
std::string strSentinel = mn.lastPing.GetSentinelString();
if (strFilter !="" && strSentinel.find(strFilter) == std::string::npos &&
strOutpoint.find(strFilter) == std::string::npos) continue;
obj.push_back(Pair(strOutpoint, strSentinel));
Expand All @@ -589,7 +589,7 @@ UniValue masternodelist(const JSONRPCRequest& request)
CBitcoinAddress(mn.pubKeyCollateralAddress.GetID()).ToString() << " " <<
(int64_t)mn.lastPing.sigTime << " " << std::setw(8) <<
(int64_t)(mn.lastPing.sigTime - mn.sigTime) << " " <<
SafeIntVersionToString(mn.lastPing.nSentinelVersion) << " " <<
mn.lastPing.GetSentinelString() << " " <<
(mn.lastPing.fSentinelIsCurrent ? "current" : "expired") << " " <<
mn.addr.ToString();
std::string strInfo = streamInfo.str();
Expand All @@ -603,7 +603,7 @@ UniValue masternodelist(const JSONRPCRequest& request)
mn.GetStatus() << " " <<
mn.nProtocolVersion << " " <<
mn.lastPing.nDaemonVersion << " " <<
SafeIntVersionToString(mn.lastPing.nSentinelVersion) << " " <<
mn.lastPing.GetSentinelString() << " " <<
(mn.lastPing.fSentinelIsCurrent ? "current" : "expired") << " " <<
(int64_t)mn.lastPing.sigTime << " " <<
(int64_t)(mn.lastPing.sigTime - mn.sigTime) << " " <<
Expand All @@ -617,8 +617,8 @@ UniValue masternodelist(const JSONRPCRequest& request)
objMN.push_back(Pair("payee", CBitcoinAddress(mn.pubKeyCollateralAddress.GetID()).ToString()));
objMN.push_back(Pair("status", mn.GetStatus()));
objMN.push_back(Pair("protocol", mn.nProtocolVersion));
objMN.push_back(Pair("daemonversion", mn.lastPing.nDaemonVersion > DEFAULT_DAEMON_VERSION ? FormatVersion(mn.lastPing.nDaemonVersion) : "Unknown"));
objMN.push_back(Pair("sentinelversion", mn.lastPing.nSentinelVersion > DEFAULT_SENTINEL_VERSION ? SafeIntVersionToString(mn.lastPing.nSentinelVersion) : "Unknown"));
objMN.push_back(Pair("daemonversion", mn.lastPing.GetDaemonString()));
objMN.push_back(Pair("sentinelversion", mn.lastPing.GetSentinelString()));
objMN.push_back(Pair("sentinelstate", (mn.lastPing.fSentinelIsCurrent ? "current" : "expired")));
objMN.push_back(Pair("lastseen", (int64_t)mn.lastPing.sigTime));
objMN.push_back(Pair("activeseconds", (int64_t)(mn.lastPing.sigTime - mn.sigTime)));
Expand Down