Remove support for "masternode list rank"

This commit is contained in:
Alexander Block 2018-12-17 16:02:12 +01:00
parent adc2ec2253
commit 0fe97a0459

View File

@ -816,7 +816,7 @@ UniValue masternodelist(const JSONRPCRequest& request)
strMode != "addr" && strMode != "full" && strMode != "info" && strMode != "json" && strMode != "addr" && strMode != "full" && strMode != "info" && strMode != "json" &&
strMode != "lastpaidtime" && strMode != "lastpaidblock" && strMode != "lastpaidtime" && strMode != "lastpaidblock" &&
strMode != "payee" && strMode != "pubkey" && strMode != "payee" && strMode != "pubkey" &&
strMode != "rank" && strMode != "status")) strMode != "status"))
{ {
masternode_list_help(); masternode_list_help();
} }
@ -831,107 +831,98 @@ UniValue masternodelist(const JSONRPCRequest& request)
} }
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);
if (strMode == "rank") { std::map<COutPoint, CMasternode> mapMasternodes = mnodeman.GetFullMasternodeMap();
CMasternodeMan::rank_pair_vec_t vMasternodeRanks; for (const auto& mnpair : mapMasternodes) {
mnodeman.GetMasternodeRanks(vMasternodeRanks); CMasternode mn = mnpair.second;
for (const auto& rankpair : vMasternodeRanks) { std::string strOutpoint = mnpair.first.ToStringShort();
std::string strOutpoint = rankpair.second.outpoint.ToStringShort();
if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) continue; CScript payeeScript;
obj.push_back(Pair(strOutpoint, rankpair.first)); if (deterministicMNManager->IsDeterministicMNsSporkActive()) {
auto dmn = deterministicMNManager->GetListAtChainTip().GetMNByCollateral(mn.outpoint);
if (dmn) {
payeeScript = dmn->pdmnState->scriptPayout;
}
} else {
payeeScript = GetScriptForDestination(mn.keyIDCollateralAddress);
} }
} else {
std::map<COutPoint, CMasternode> mapMasternodes = mnodeman.GetFullMasternodeMap();
for (const auto& mnpair : mapMasternodes) {
CMasternode mn = mnpair.second;
std::string strOutpoint = mnpair.first.ToStringShort();
CScript payeeScript; CTxDestination payeeDest;
if (deterministicMNManager->IsDIP3Active()) { std::string payeeStr = "UNKOWN";
auto dmn = deterministicMNManager->GetListAtChainTip().GetMNByCollateral(mn.outpoint); if (ExtractDestination(payeeScript, payeeDest)) {
if (dmn) { payeeStr = CBitcoinAddress(payeeDest).ToString();
payeeScript = dmn->pdmnState->scriptPayout; }
}
} else {
payeeScript = GetScriptForDestination(mn.keyIDCollateralAddress);
}
CTxDestination payeeDest; if (strMode == "addr") {
std::string payeeStr = "UNKOWN"; std::string strAddress = mn.addr.ToString();
if (ExtractDestination(payeeScript, payeeDest)) { if (strFilter !="" && strAddress.find(strFilter) == std::string::npos &&
payeeStr = CBitcoinAddress(payeeDest).ToString(); strOutpoint.find(strFilter) == std::string::npos) continue;
} obj.push_back(Pair(strOutpoint, strAddress));
} else if (strMode == "full") {
if (strMode == "addr") { std::ostringstream streamFull;
std::string strAddress = mn.addr.ToString(); streamFull << std::setw(18) <<
if (strFilter !="" && strAddress.find(strFilter) == std::string::npos && mn.GetStatus() << " " <<
strOutpoint.find(strFilter) == std::string::npos) continue; payeeStr << " " <<
obj.push_back(Pair(strOutpoint, strAddress)); mn.GetLastPaidTime() << " " << std::setw(6) <<
} else if (strMode == "full") { mn.GetLastPaidBlock() << " " <<
std::ostringstream streamFull; mn.addr.ToString();
streamFull << std::setw(18) << std::string strFull = streamFull.str();
mn.GetStatus() << " " << if (strFilter !="" && strFull.find(strFilter) == std::string::npos &&
payeeStr << " " << strOutpoint.find(strFilter) == std::string::npos) continue;
mn.GetLastPaidTime() << " " << std::setw(6) << obj.push_back(Pair(strOutpoint, strFull));
mn.GetLastPaidBlock() << " " << } else if (strMode == "info") {
mn.addr.ToString(); std::ostringstream streamInfo;
std::string strFull = streamFull.str(); streamInfo << std::setw(18) <<
if (strFilter !="" && strFull.find(strFilter) == std::string::npos && mn.GetStatus() << " " <<
strOutpoint.find(strFilter) == std::string::npos) continue; payeeStr << " " <<
obj.push_back(Pair(strOutpoint, strFull)); mn.addr.ToString();
} else if (strMode == "info") { std::string strInfo = streamInfo.str();
std::ostringstream streamInfo; if (strFilter !="" && strInfo.find(strFilter) == std::string::npos &&
streamInfo << std::setw(18) << strOutpoint.find(strFilter) == std::string::npos) continue;
mn.GetStatus() << " " << obj.push_back(Pair(strOutpoint, strInfo));
payeeStr << " " << } else if (strMode == "json") {
mn.addr.ToString(); std::ostringstream streamInfo;
std::string strInfo = streamInfo.str(); streamInfo << mn.addr.ToString() << " " <<
if (strFilter !="" && strInfo.find(strFilter) == std::string::npos && CBitcoinAddress(mn.pubKeyCollateralAddress.GetID()).ToString() << " " <<
strOutpoint.find(strFilter) == std::string::npos) continue; mn.GetStatus() << " " <<
obj.push_back(Pair(strOutpoint, strInfo)); mn.GetLastPaidTime() << " " <<
} else if (strMode == "json") { mn.GetLastPaidBlock();
std::ostringstream streamInfo; std::string strInfo = streamInfo.str();
streamInfo << mn.addr.ToString() << " " << if (strFilter !="" && strInfo.find(strFilter) == std::string::npos &&
CBitcoinAddress(mn.pubKeyCollateralAddress.GetID()).ToString() << " " << strOutpoint.find(strFilter) == std::string::npos) continue;
mn.GetStatus() << " " << UniValue objMN(UniValue::VOBJ);
mn.GetLastPaidTime() << " " << objMN.push_back(Pair("address", mn.addr.ToString()));
mn.GetLastPaidBlock(); objMN.push_back(Pair("payee", CBitcoinAddress(mn.pubKeyCollateralAddress.GetID()).ToString()));
std::string strInfo = streamInfo.str(); objMN.push_back(Pair("status", mn.GetStatus()));
if (strFilter !="" && strInfo.find(strFilter) == std::string::npos && objMN.push_back(Pair("lastpaidtime", mn.GetLastPaidTime()));
strOutpoint.find(strFilter) == std::string::npos) continue; objMN.push_back(Pair("lastpaidblock", mn.GetLastPaidBlock()));
UniValue objMN(UniValue::VOBJ); obj.push_back(Pair(strOutpoint, objMN));
objMN.push_back(Pair("address", mn.addr.ToString())); } else if (strMode == "lastpaidblock") {
objMN.push_back(Pair("payee", CBitcoinAddress(mn.pubKeyCollateralAddress.GetID()).ToString())); if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) continue;
objMN.push_back(Pair("status", mn.GetStatus())); obj.push_back(Pair(strOutpoint, mn.GetLastPaidBlock()));
objMN.push_back(Pair("lastpaidtime", mn.GetLastPaidTime())); } else if (strMode == "lastpaidtime") {
objMN.push_back(Pair("lastpaidblock", mn.GetLastPaidBlock())); if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) continue;
obj.push_back(Pair(strOutpoint, objMN)); obj.push_back(Pair(strOutpoint, mn.GetLastPaidTime()));
} else if (strMode == "lastpaidblock") { } else if (strMode == "payee") {
if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) continue; if (strFilter !="" && payeeStr.find(strFilter) == std::string::npos &&
obj.push_back(Pair(strOutpoint, mn.GetLastPaidBlock())); strOutpoint.find(strFilter) == std::string::npos) continue;
} else if (strMode == "lastpaidtime") { obj.push_back(Pair(strOutpoint, payeeStr));
if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) continue; } else if (strMode == "keyIDOwner") {
obj.push_back(Pair(strOutpoint, mn.GetLastPaidTime())); if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) continue;
} else if (strMode == "payee") { obj.push_back(Pair(strOutpoint, HexStr(mn.keyIDOwner)));
if (strFilter !="" && payeeStr.find(strFilter) == std::string::npos && } else if (strMode == "keyIDOperator") {
strOutpoint.find(strFilter) == std::string::npos) continue; if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) continue;
obj.push_back(Pair(strOutpoint, payeeStr)); obj.push_back(Pair(strOutpoint, HexStr(mn.legacyKeyIDOperator)));
} else if (strMode == "keyIDOwner") { } else if (strMode == "keyIDVoting") {
if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) continue; if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) continue;
obj.push_back(Pair(strOutpoint, HexStr(mn.keyIDOwner))); obj.push_back(Pair(strOutpoint, HexStr(mn.keyIDVoting)));
} else if (strMode == "keyIDOperator") { } else if (strMode == "status") {
if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) continue; std::string strStatus = mn.GetStatus();
obj.push_back(Pair(strOutpoint, HexStr(mn.legacyKeyIDOperator))); if (strFilter !="" && strStatus.find(strFilter) == std::string::npos &&
} else if (strMode == "keyIDVoting") { strOutpoint.find(strFilter) == std::string::npos) continue;
if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) continue; obj.push_back(Pair(strOutpoint, strStatus));
obj.push_back(Pair(strOutpoint, HexStr(mn.keyIDVoting)));
} else if (strMode == "status") {
std::string strStatus = mn.GetStatus();
if (strFilter !="" && strStatus.find(strFilter) == std::string::npos &&
strOutpoint.find(strFilter) == std::string::npos) continue;
obj.push_back(Pair(strOutpoint, strStatus));
}
} }
} }
return obj; return obj;
} }