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

consistent JSON return value for failed vote #1001

Merged
merged 2 commits into from
Sep 12, 2016
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
17 changes: 12 additions & 5 deletions src/rpcgovernance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ UniValue gobject(const UniValue& params, bool fHelp)
std::string strMasterNodeSignMessage;

UniValue statusObj(UniValue::VOBJ);
UniValue returnObj(UniValue::VOBJ);

CMasternode* pmn = mnodeman.Find(activeMasternode.pubKeyMasternode);
if(pmn == NULL)
Expand All @@ -252,7 +253,10 @@ UniValue gobject(const UniValue& params, bool fHelp)
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("errorMessage", "Can't find masternode by pubkey"));
resultsObj.push_back(Pair("dash.conf", statusObj));
return "Can't find masternode by pubkey";

returnObj.push_back(Pair("overall", strprintf("Voted successfully %d time(s) and failed %d time(s).", success, failed)));
returnObj.push_back(Pair("detail", resultsObj));
return returnObj;
}

CGovernanceVote vote(pmn->vin, hash, eVoteSignal, eVoteOutcome);
Expand All @@ -261,7 +265,9 @@ UniValue gobject(const UniValue& params, bool fHelp)
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("errorMessage", "Failure to sign."));
resultsObj.push_back(Pair("dash.conf", statusObj));
return "Failure to sign.";
returnObj.push_back(Pair("overall", strprintf("Voted successfully %d time(s) and failed %d time(s).", success, failed)));
returnObj.push_back(Pair("detail", resultsObj));
return returnObj;
}

std::string strError = "";
Expand All @@ -272,12 +278,12 @@ UniValue gobject(const UniValue& params, bool fHelp)
statusObj.push_back(Pair("result", "success"));
} else {
failed++;
statusObj.push_back(Pair("result", strError.c_str()));
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("errorMessage", strError.c_str()));
}

resultsObj.push_back(Pair("dash.conf", statusObj));

UniValue returnObj(UniValue::VOBJ);
returnObj.push_back(Pair("overall", strprintf("Voted successfully %d time(s) and failed %d time(s).", success, failed)));
returnObj.push_back(Pair("detail", resultsObj));

Expand Down Expand Up @@ -385,7 +391,8 @@ UniValue gobject(const UniValue& params, bool fHelp)
statusObj.push_back(Pair("result", "success"));
} else {
failed++;
statusObj.push_back(Pair("result", strError.c_str()));
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("errorMessage", strError.c_str()));
}

resultsObj.push_back(Pair(mne.getAlias(), statusObj));
Expand Down