From 0d324eafa82fc3bd1c171ac1e7f4bf1a9c5300c6 Mon Sep 17 00:00:00 2001 From: Tim Flynn Date: Thu, 29 Sep 2016 21:48:18 -0400 Subject: [PATCH] rpcgovernance improvements (#1052) * rpcgovernance improvements - Modified govject get to return full object data along with vote counts - Cleaned up vote count reporting code * Added cached flags to gobject get output --- src/rpcgovernance.cpp | 46 ++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/src/rpcgovernance.cpp b/src/rpcgovernance.cpp index 127170102..c5e1ca286 100644 --- a/src/rpcgovernance.cpp +++ b/src/rpcgovernance.cpp @@ -573,10 +573,10 @@ UniValue gobject(const UniValue& params, bool fHelp) bObj.push_back(Pair("CollateralHash", pGovObj->nCollateralHash.ToString())); // REPORT STATUS FOR FUNDING VOTES SPECIFICALLY - bObj.push_back(Pair("AbsoluteYesCount", (int64_t)pGovObj->GetYesCount(VOTE_SIGNAL_FUNDING)-(int64_t)pGovObj->GetNoCount(VOTE_SIGNAL_FUNDING))); - bObj.push_back(Pair("YesCount", (int64_t)pGovObj->GetYesCount(VOTE_SIGNAL_FUNDING))); - bObj.push_back(Pair("NoCount", (int64_t)pGovObj->GetNoCount(VOTE_SIGNAL_FUNDING))); - bObj.push_back(Pair("AbstainCount", (int64_t)pGovObj->GetAbstainCount(VOTE_SIGNAL_FUNDING))); + bObj.push_back(Pair("AbsoluteYesCount", pGovObj->GetAbsoluteYesCount(VOTE_SIGNAL_FUNDING))); + bObj.push_back(Pair("YesCount", pGovObj->GetYesCount(VOTE_SIGNAL_FUNDING))); + bObj.push_back(Pair("NoCount", pGovObj->GetNoCount(VOTE_SIGNAL_FUNDING))); + bObj.push_back(Pair("AbstainCount", pGovObj->GetAbstainCount(VOTE_SIGNAL_FUNDING))); // REPORT VALIDITY AND CACHING FLAGS FOR VARIOUS SETTINGS std::string strError = ""; @@ -613,6 +613,8 @@ UniValue gobject(const UniValue& params, bool fHelp) // REPORT BASIC OBJECT STATS UniValue objResult(UniValue::VOBJ); + objResult.push_back(Pair("DataHex", pGovObj->GetDataAsHex())); + objResult.push_back(Pair("DataString", pGovObj->GetDataAsString())); objResult.push_back(Pair("Hash", pGovObj->GetHash().ToString())); objResult.push_back(Pair("CollateralHash", pGovObj->nCollateralHash.ToString())); @@ -620,40 +622,44 @@ UniValue gobject(const UniValue& params, bool fHelp) // -- FUNDING VOTING RESULTS UniValue objFundingResult(UniValue::VOBJ); - objFundingResult.push_back(Pair("AbsoluteYesCount", (int64_t)pGovObj->GetYesCount(VOTE_SIGNAL_FUNDING)-(int64_t)pGovObj->GetNoCount(VOTE_SIGNAL_FUNDING))); - objFundingResult.push_back(Pair("YesCount", (int64_t)pGovObj->GetYesCount(VOTE_SIGNAL_FUNDING))); - objFundingResult.push_back(Pair("NoCount", (int64_t)pGovObj->GetNoCount(VOTE_SIGNAL_FUNDING))); - objFundingResult.push_back(Pair("AbstainCount", (int64_t)pGovObj->GetAbstainCount(VOTE_SIGNAL_FUNDING))); + objFundingResult.push_back(Pair("AbsoluteYesCount", pGovObj->GetAbsoluteYesCount(VOTE_SIGNAL_FUNDING))); + objFundingResult.push_back(Pair("YesCount", pGovObj->GetYesCount(VOTE_SIGNAL_FUNDING))); + objFundingResult.push_back(Pair("NoCount", pGovObj->GetNoCount(VOTE_SIGNAL_FUNDING))); + objFundingResult.push_back(Pair("AbstainCount", pGovObj->GetAbstainCount(VOTE_SIGNAL_FUNDING))); objResult.push_back(Pair("FundingResult", objFundingResult)); // -- VALIDITY VOTING RESULTS UniValue objValid(UniValue::VOBJ); - objValid.push_back(Pair("AbsoluteYesCount", (int64_t)pGovObj->GetYesCount(VOTE_SIGNAL_VALID)-(int64_t)pGovObj->GetNoCount(VOTE_SIGNAL_VALID))); - objValid.push_back(Pair("YesCount", (int64_t)pGovObj->GetYesCount(VOTE_SIGNAL_VALID))); - objValid.push_back(Pair("NoCount", (int64_t)pGovObj->GetNoCount(VOTE_SIGNAL_VALID))); - objValid.push_back(Pair("AbstainCount", (int64_t)pGovObj->GetAbstainCount(VOTE_SIGNAL_VALID))); + objValid.push_back(Pair("AbsoluteYesCount", pGovObj->GetAbsoluteYesCount(VOTE_SIGNAL_VALID))); + objValid.push_back(Pair("YesCount", pGovObj->GetYesCount(VOTE_SIGNAL_VALID))); + objValid.push_back(Pair("NoCount", pGovObj->GetNoCount(VOTE_SIGNAL_VALID))); + objValid.push_back(Pair("AbstainCount", pGovObj->GetAbstainCount(VOTE_SIGNAL_VALID))); objResult.push_back(Pair("ValidResult", objValid)); // -- DELETION CRITERION VOTING RESULTS UniValue objDelete(UniValue::VOBJ); - objDelete.push_back(Pair("AbsoluteYesCount", (int64_t)pGovObj->GetYesCount(VOTE_SIGNAL_DELETE)-(int64_t)pGovObj->GetNoCount(VOTE_SIGNAL_DELETE))); - objDelete.push_back(Pair("YesCount", (int64_t)pGovObj->GetYesCount(VOTE_SIGNAL_DELETE))); - objDelete.push_back(Pair("NoCount", (int64_t)pGovObj->GetNoCount(VOTE_SIGNAL_DELETE))); - objDelete.push_back(Pair("AbstainCount", (int64_t)pGovObj->GetAbstainCount(VOTE_SIGNAL_DELETE))); + objDelete.push_back(Pair("AbsoluteYesCount", pGovObj->GetAbsoluteYesCount(VOTE_SIGNAL_DELETE))); + objDelete.push_back(Pair("YesCount", pGovObj->GetYesCount(VOTE_SIGNAL_DELETE))); + objDelete.push_back(Pair("NoCount", pGovObj->GetNoCount(VOTE_SIGNAL_DELETE))); + objDelete.push_back(Pair("AbstainCount", pGovObj->GetAbstainCount(VOTE_SIGNAL_DELETE))); objResult.push_back(Pair("DeleteResult", objDelete)); // -- ENDORSED VIA MASTERNODE-ELECTED BOARD UniValue objEndorsed(UniValue::VOBJ); - objEndorsed.push_back(Pair("AbsoluteYesCount", (int64_t)pGovObj->GetYesCount(VOTE_SIGNAL_ENDORSED)-(int64_t)pGovObj->GetNoCount(VOTE_SIGNAL_ENDORSED))); - objEndorsed.push_back(Pair("YesCount", (int64_t)pGovObj->GetYesCount(VOTE_SIGNAL_ENDORSED))); - objEndorsed.push_back(Pair("NoCount", (int64_t)pGovObj->GetNoCount(VOTE_SIGNAL_ENDORSED))); - objEndorsed.push_back(Pair("AbstainCount", (int64_t)pGovObj->GetAbstainCount(VOTE_SIGNAL_ENDORSED))); + objEndorsed.push_back(Pair("AbsoluteYesCount", pGovObj->GetAbsoluteYesCount(VOTE_SIGNAL_ENDORSED))); + objEndorsed.push_back(Pair("YesCount", pGovObj->GetYesCount(VOTE_SIGNAL_ENDORSED))); + objEndorsed.push_back(Pair("NoCount", pGovObj->GetNoCount(VOTE_SIGNAL_ENDORSED))); + objEndorsed.push_back(Pair("AbstainCount", pGovObj->GetAbstainCount(VOTE_SIGNAL_ENDORSED))); objResult.push_back(Pair("EndorsedResult", objEndorsed)); // -- std::string strError = ""; objResult.push_back(Pair("fLocalValidity", pGovObj->IsValidLocally(chainActive.Tip(), strError, false))); + objResult.push_back(Pair("IsValidReason", strError.c_str())); objResult.push_back(Pair("fCachedValid", pGovObj->fCachedValid)); + objResult.push_back(Pair("fCachedFunding", pGovObj->fCachedFunding)); + objResult.push_back(Pair("fCachedDelete", pGovObj->fCachedDelete)); + objResult.push_back(Pair("fCachedEndorsed", pGovObj->fCachedEndorsed)); return objResult; }