Skip to content

V0.11.2.x fix masternodelist #218

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

Merged
merged 4 commits into from
Mar 4, 2015
Merged
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
80 changes: 41 additions & 39 deletions src/rpcdarksend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,17 +579,17 @@ Value masternodelist(const Array& params, bool fHelp)
"masternodelist ( \"mode\" \"filter\" )\n"
"Get a list of masternodes in different modes\n"
"\nArguments:\n"
"1. \"mode\" (string, optional, defauls = active) The mode to run list in\n"
"2. \"filter\" (string, optional) Filter results, can be applied in few modes only\n"
"1. \"mode\" (string, optional/required to use filter, defaults = active) The mode to run list in\n"
"2. \"filter\" (string, optional) Filter results. Partial match by IP by default in all modes, additional matches in some modes\n"
"\nAvailable modes:\n"
" active - Print '1' if active and '0' otherwise (can be filtered, exact match)\n"
" active - Print '1' if active and '0' otherwise (can be additionally filtered by 'true' (active only) / 'false' (non-active only))\n"
" activeseconds - Print number of seconds masternode recognized by the network as enabled\n"
" full - Print info in format 'active | protocol | pubkey | vin | lastseen | activeseconds' (can be filtered, partial match)\n"
" full - Print info in format 'active protocol pubkey vin lastseen activeseconds' (can be additionally filtered, partial match)\n"
" lastseen - Print timestamp of when a masternode was last seen on the network\n"
" protocol - Print protocol of a masternode (can be filtered, exact match)\n"
" pubkey - Print public key associated with a masternode (can be filtered, partial match)\n"
" protocol - Print protocol of a masternode (can be additionally filtered, exact match))\n"
" pubkey - Print public key associated with a masternode (can be additionally filtered, partial match)\n"
" rank - Print rank of a masternode based on current block\n"
" vin - Print vin associated with a masternode (can be filtered, partial match)\n"
" vin - Print vin associated with a masternode (can be additionally filtered, partial match)\n"
);
}

Expand All @@ -599,56 +599,58 @@ Value masternodelist(const Array& params, bool fHelp)

std::string strAddr = mn.addr.ToString().c_str();
if(strMode == "active"){
if(strFilter !="" && strFilter != boost::lexical_cast<std::string>(mn.IsEnabled()) &&
if(strFilter !="" && strFilter != (mn.IsEnabled() ? "true" : "false") &&
mn.addr.ToString().find(strFilter) == string::npos) continue;
obj.push_back(Pair(strAddr, (int)mn.IsEnabled()));
} else if (strMode == "vin") {
if(strFilter !="" && mn.vin.prevout.hash.ToString().find(strFilter) == string::npos &&
mn.addr.ToString().find(strFilter) == string::npos) continue;
obj.push_back(Pair(strAddr, mn.vin.prevout.hash.ToString().c_str()));
} else if (strMode == "pubkey") {
} else if (strMode == "activeseconds") {
if(strFilter !="" && mn.addr.ToString().find(strFilter) == string::npos) continue;
obj.push_back(Pair(strAddr, (int64_t)(mn.lastTimeSeen - mn.sigTime)));
} else if (strMode == "full") {
CScript pubkey;
pubkey.SetDestination(mn.pubkey.GetID());
CTxDestination address1;
ExtractDestination(pubkey, address1);
CBitcoinAddress address2(address1);

if(strFilter !="" && address2.ToString().find(strFilter) == string::npos &&
mn.addr.ToString().find(strFilter) == string::npos) continue;
obj.push_back(Pair(strAddr, address2.ToString().c_str()));
std::ostringstream addrStream;
addrStream << setw(21) << strAddr;

std::ostringstream stringStream;
stringStream << (mn.IsEnabled() ? "1" : "0") << " " <<
mn.protocolVersion << " " <<
address2.ToString() << " " <<
mn.vin.prevout.hash.ToString() << " " <<
mn.lastTimeSeen << " " << setw(8) <<
(mn.lastTimeSeen - mn.sigTime);
std::string output = stringStream.str();
stringStream << " " << strAddr;
if(strFilter !="" && stringStream.str().find(strFilter) == string::npos &&
mn.addr.ToString().find(strFilter) == string::npos) continue;
obj.push_back(Pair(addrStream.str(), output));
} else if (strMode == "lastseen") {
if(strFilter !="" && mn.addr.ToString().find(strFilter) == string::npos) continue;
obj.push_back(Pair(strAddr, (int64_t)mn.lastTimeSeen));
} else if (strMode == "protocol") {
if(strFilter !="" && strFilter != boost::lexical_cast<std::string>(mn.protocolVersion) &&
mn.addr.ToString().find(strFilter) == string::npos) continue;
obj.push_back(Pair(strAddr, (int64_t)mn.protocolVersion));
} else if (strMode == "lastseen") {
if(strFilter !="" && mn.addr.ToString().find(strFilter) == string::npos) continue;

obj.push_back(Pair(strAddr, (int64_t)mn.lastTimeSeen));
} else if (strMode == "activeseconds") {
if(strFilter !="" && mn.addr.ToString().find(strFilter) == string::npos) continue;

obj.push_back(Pair(strAddr, (int64_t)(mn.lastTimeSeen - mn.sigTime)));
} else if (strMode == "rank") {
if(strFilter !="" && mn.addr.ToString().find(strFilter) == string::npos) continue;
obj.push_back(Pair(strAddr, (int)(mnodeman.GetMasternodeRank(mn.vin, chainActive.Tip()->nHeight))));
} else if (strMode == "full") {
} else if (strMode == "pubkey") {
CScript pubkey;
pubkey.SetDestination(mn.pubkey.GetID());
CTxDestination address1;
ExtractDestination(pubkey, address1);
CBitcoinAddress address2(address1);

std::ostringstream stringStream;
stringStream << (mn.IsEnabled() ? "1" : "0") << " | " <<
mn.protocolVersion << " | " <<
address2.ToString() << " | " <<
mn.vin.prevout.hash.ToString() << " | " <<
mn.lastTimeSeen << " | " <<
(mn.lastTimeSeen - mn.sigTime);
std::string output = stringStream.str();
stringStream << " " << strAddr;
if(strFilter !="" && stringStream.str().find(strFilter) == string::npos) continue;
obj.push_back(Pair(strAddr, output));
if(strFilter !="" && address2.ToString().find(strFilter) == string::npos &&
mn.addr.ToString().find(strFilter) == string::npos) continue;
obj.push_back(Pair(strAddr, address2.ToString().c_str()));
} else if (strMode == "rank") {
if(strFilter !="" && mn.addr.ToString().find(strFilter) == string::npos) continue;
obj.push_back(Pair(strAddr, (int)(mnodeman.GetMasternodeRank(mn.vin, chainActive.Tip()->nHeight))));
} else if (strMode == "vin") {
if(strFilter !="" && mn.vin.prevout.hash.ToString().find(strFilter) == string::npos &&
mn.addr.ToString().find(strFilter) == string::npos) continue;
obj.push_back(Pair(strAddr, mn.vin.prevout.hash.ToString().c_str()));
}
}
return obj;
Expand Down