Skip to content

Commit

Permalink
add rpc and fix exclude count
Browse files Browse the repository at this point in the history
  • Loading branch information
alex v committed Oct 27, 2020
1 parent f8ff873 commit a6ac923
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/consensus/dao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2344,7 +2344,7 @@ bool CConsultationAnswer::IsConsensusAccepted(const CStateViewCache& view) const
if (nVersion & CConsultationAnswer::EXCLUDE_VERSION)
exclude = nExclude;

return nVotes >= (GetConsensusParameter(Consensus::CONSENSUS_PARAM_VOTING_CYCLE_LENGTH, view) * nMinimumQuorum) - exclude;
return nVotes >= ((GetConsensusParameter(Consensus::CONSENSUS_PARAM_VOTING_CYCLE_LENGTH, view) - exclude) * nMinimumQuorum);

}

Expand Down Expand Up @@ -2645,7 +2645,7 @@ bool CPaymentRequest::IsAccepted(const CStateViewCache& view) const
if (nVersion & ABSTAIN_VOTE_VERSION)
nTotalVotes += nVotesAbs;

return nTotalVotes > (GetConsensusParameter(Consensus::CONSENSUS_PARAM_VOTING_CYCLE_LENGTH, view) * nMinimumQuorum) - exclude
return nTotalVotes > ((GetConsensusParameter(Consensus::CONSENSUS_PARAM_VOTING_CYCLE_LENGTH, view) - exclude) * nMinimumQuorum)
&& ((float)nVotesYes > ((float)(nTotalVotes) * GetConsensusParameter(Consensus::CONSENSUS_PARAM_PAYMENT_REQUEST_MIN_ACCEPT, view) / 10000.0));
}

Expand All @@ -2663,7 +2663,7 @@ bool CPaymentRequest::IsRejected(const CStateViewCache& view) const {
if (nVersion & CPaymentRequest::EXCLUDE_VERSION)
exclude = nExclude;

return nTotalVotes > (GetConsensusParameter(Consensus::CONSENSUS_PARAM_VOTING_CYCLE_LENGTH, view) * nMinimumQuorum) - exclude
return nTotalVotes > ((GetConsensusParameter(Consensus::CONSENSUS_PARAM_VOTING_CYCLE_LENGTH, view) - exclude) * nMinimumQuorum)
&& ((float)nVotesNo > ((float)(nTotalVotes) * GetConsensusParameter(Consensus::CONSENSUS_PARAM_PAYMENT_REQUEST_MIN_REJECT, view) / 10000.0));
}

Expand All @@ -2686,7 +2686,7 @@ bool CProposal::IsAccepted(const CStateViewCache& view) const
if (nVersion & CProposal::EXCLUDE_VERSION)
exclude = nExclude;

return nTotalVotes > (GetConsensusParameter(Consensus::CONSENSUS_PARAM_VOTING_CYCLE_LENGTH, view) * nMinimumQuorum) - exclude
return nTotalVotes > ((GetConsensusParameter(Consensus::CONSENSUS_PARAM_VOTING_CYCLE_LENGTH, view) - exclude) * nMinimumQuorum)
&& ((float)nVotesYes > ((float)(nTotalVotes) * GetConsensusParameter(Consensus::CONSENSUS_PARAM_PROPOSAL_MIN_ACCEPT, view) / 10000.0));
}

Expand All @@ -2705,7 +2705,7 @@ bool CProposal::IsRejected(const CStateViewCache& view) const
if (nVersion & CProposal::EXCLUDE_VERSION)
exclude = nExclude;

return nTotalVotes > (GetConsensusParameter(Consensus::CONSENSUS_PARAM_VOTING_CYCLE_LENGTH, view) * nMinimumQuorum) - exclude
return nTotalVotes > ((GetConsensusParameter(Consensus::CONSENSUS_PARAM_VOTING_CYCLE_LENGTH, view) - exclude) * nMinimumQuorum)
&& ((float)nVotesNo > ((float)(nTotalVotes) * GetConsensusParameter(Consensus::CONSENSUS_PARAM_PROPOSAL_MIN_REJECT, view)/ 10000.0));
}

Expand Down
1 change: 1 addition & 0 deletions src/rpc/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "getaddressutxos", 0},
{ "getaddressmempool", 0},
{ "staking", 0 },
{ "setexclude", 0 },
{ "coinbaseoutputs", 0 },
{ "coinstakeoutputs", 0 },
{ "coinstakeinputs", 0 },
Expand Down
22 changes: 22 additions & 0 deletions src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,27 @@ UniValue stakervote(const UniValue& params, bool fHelp)
return "";
}

UniValue setexclude(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"setexclude bool\n"
"\nSets the node blocks to be excluded from votings.\n"
"\nArguments:\n"
"1. \"bool\" (bool, required) Whether to turn on or off.\n"
+ HelpExampleCli("setexclude", "true")
);

if (!params[0].isBool())
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, argument 1 must be a boolean");

SoftSetArg("-excludevote", params[0].get_bool() ? "1" : "0", true);
RemoveConfigFile("excludevote");
WriteConfigFile("excludevote", params[0].get_bool() ? "1" : "0");

return "";
}

UniValue createproposal(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
Expand Down Expand Up @@ -4499,6 +4520,7 @@ static const CRPCCommand commands[] =
{ "dao", "proposeanswer", &proposeanswer, false },
{ "dao", "proposeconsensuschange", &proposeconsensuschange, false },
{ "dao", "getconsensusparameters", &getconsensusparameters, false },
{ "dao", "setexclude", &setexclude, false },
{ "wallet", "stakervote", &stakervote, false },
{ "dao", "support", &support, false },
{ "dao", "supportlist", &supportlist, false },
Expand Down

0 comments on commit a6ac923

Please sign in to comment.