Skip to content

Commit

Permalink
Fix spork RPC to use new spork defs
Browse files Browse the repository at this point in the history
This also removes the need for SPORK_START/SPORK_END
  • Loading branch information
codablock committed May 29, 2019
1 parent 0cb0840 commit 9756cb6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
14 changes: 6 additions & 8 deletions src/rpc/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,16 +253,14 @@ UniValue spork(const JSONRPCRequest& request)
std:: string strCommand = request.params[0].get_str();
if (strCommand == "show") {
UniValue ret(UniValue::VOBJ);
for(int nSporkID = SPORK_START; nSporkID <= SPORK_END; nSporkID++){
if(sporkManager.GetSporkNameByID(nSporkID) != "Unknown")
ret.push_back(Pair(sporkManager.GetSporkNameByID(nSporkID), sporkManager.GetSporkValue(nSporkID)));
for (const auto& sporkDef : sporkDefs) {
ret.push_back(Pair(sporkDef.name, sporkManager.GetSporkValue(sporkDef.sporkId)));
}
return ret;
} else if(strCommand == "active"){
UniValue ret(UniValue::VOBJ);
for(int nSporkID = SPORK_START; nSporkID <= SPORK_END; nSporkID++){
if(sporkManager.GetSporkNameByID(nSporkID) != "Unknown")
ret.push_back(Pair(sporkManager.GetSporkNameByID(nSporkID), sporkManager.IsSporkActive(nSporkID)));
for (const auto& sporkDef : sporkDefs) {
ret.push_back(Pair(sporkDef.name, sporkManager.IsSporkActive(sporkDef.sporkId)));
}
return ret;
}
Expand Down Expand Up @@ -291,8 +289,8 @@ UniValue spork(const JSONRPCRequest& request)
+ HelpExampleRpc("spork", "\"show\""));
} else {
// advanced mode, update spork values
int nSporkID = sporkManager.GetSporkIDByName(request.params[0].get_str());
if(nSporkID == -1)
SporkId nSporkID = sporkManager.GetSporkIDByName(request.params[0].get_str());
if(nSporkID == SPORK_INVALID)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid spork name");

if (!g_connman)
Expand Down
2 changes: 0 additions & 2 deletions src/spork.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ enum SporkId : int32_t {
SPORK_19_CHAINLOCKS_ENABLED = 10018,
SPORK_20_INSTANTSEND_LLMQ_BASED = 10019,

SPORK_START = SPORK_2_INSTANTSEND_ENABLED,
SPORK_END = SPORK_20_INSTANTSEND_LLMQ_BASED,
SPORK_INVALID = -1,
};
template<> struct is_serializable_enum<SporkId> : std::true_type {};
Expand Down

0 comments on commit 9756cb6

Please sign in to comment.