Skip to content

Commit

Permalink
rename VoteResult variables
Browse files Browse the repository at this point in the history
  • Loading branch information
npq7721 committed Apr 6, 2024
1 parent 6526659 commit ef606d0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
26 changes: 10 additions & 16 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1631,7 +1631,7 @@ UniValue getblockchaininfo(const JSONRPCRequest &request) {
{RPCResult::Type::NUM, "threshold",
"current pass activation threshold"},
{RPCResult::Type::BOOL, "approved",
"returns false if majority of miners are not yet approved"},
"returns false if miners has not yet approved"},
}},
{RPCResult::Type::OBJ, "nodes",
"node numeric statistics about RIP1 signalling for a softfork",
Expand All @@ -1647,7 +1647,7 @@ UniValue getblockchaininfo(const JSONRPCRequest &request) {
{RPCResult::Type::NUM, "threshold",
"current pass activation threshold"},
{RPCResult::Type::BOOL, "approved",
"returns false if majority of nodes are not yet approved"},
"returns false if nodes has not approved"},
}},
}},
}},
Expand All @@ -1658,12 +1658,6 @@ UniValue getblockchaininfo(const JSONRPCRequest &request) {
+ HelpExampleRpc("getblockchaininfo", "")
},
}.Check(request);
//minerStats.pushKV("mean_percentage", state.voteStats.minerVoteResult->MeanPercent());
// minerStats.pushKV("weighted_yes", state.voteStats.minerVoteResult->GetWeightedYes());
// minerStats.pushKV("weight", state.voteStats.minerVoteResult->GetWeight());
// minerStats.pushKV("samples", state.voteStats.minerVoteResult->GetSamples());
// minerStats.pushKV("threshold", state.voteStats.currentMinerThreshold);
// minerStats.pushKV("approved", state.voteStats.minersApproved);
LOCK(cs_main);

std::string strChainName = gArgs.IsArgSet("-devnet") ? gArgs.GetDevNetName() : Params().NetworkIDString();
Expand Down Expand Up @@ -1740,21 +1734,21 @@ UniValue getblockchaininfo(const JSONRPCRequest &request) {
rv.pushKV("voting_period", update->VotingPeriod());
if (state.voteStats.currentMinerThreshold) {
UniValue minerStats(UniValue::VOBJ);
minerStats.pushKV("mean_percentage", state.voteStats.minerVoteResult.MeanPercent());
minerStats.pushKV("weighted_yes", state.voteStats.minerVoteResult.GetWeightedYes());
minerStats.pushKV("weight", state.voteStats.minerVoteResult.GetWeight());
minerStats.pushKV("samples", state.voteStats.minerVoteResult.GetSamples());
minerStats.pushKV("mean_percentage", state.voteStats.minerUpdateResult.MeanPercent());
minerStats.pushKV("weighted_yes", state.voteStats.minerUpdateResult.GetWeightedYes());
minerStats.pushKV("weight", state.voteStats.minerUpdateResult.GetWeight());
minerStats.pushKV("samples", state.voteStats.minerUpdateResult.GetSamples());
minerStats.pushKV("threshold", state.voteStats.currentMinerThreshold);
minerStats.pushKV("approved", state.voteStats.minersApproved);
rv.pushKV("miners", minerStats);

}
if (state.voteStats.currentNodeThreshold) {
UniValue minerStats(UniValue::VOBJ);
minerStats.pushKV("mean_percentage", state.voteStats.nodeVoteResult.MeanPercent());
minerStats.pushKV("weighted_yes", state.voteStats.nodeVoteResult.GetWeightedYes());
minerStats.pushKV("weight", state.voteStats.nodeVoteResult.GetWeight());
minerStats.pushKV("samples", state.voteStats.nodeVoteResult.GetSamples());
minerStats.pushKV("mean_percentage", state.voteStats.nodeUpdateResult.MeanPercent());
minerStats.pushKV("weighted_yes", state.voteStats.nodeUpdateResult.GetWeightedYes());
minerStats.pushKV("weight", state.voteStats.nodeUpdateResult.GetWeight());
minerStats.pushKV("samples", state.voteStats.nodeUpdateResult.GetSamples());
minerStats.pushKV("threshold", state.voteStats.currentNodeThreshold);
minerStats.pushKV("approved", state.voteStats.nodesApproved);
rv.pushKV("nodes", minerStats);
Expand Down
4 changes: 2 additions & 2 deletions src/update/update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ StateInfo UpdateManager::State(enum EUpdate eUpdate, const CBlockIndex *blockInd
// Check Miner votes:
{
VoteResult minerUpdateResult = minerUpdateVoting.GetVote(pIndexPrev, *update);
voteStats.minerVoteResult = minerUpdateResult;
voteStats.minerUpdateResult = minerUpdateResult;
// double confidenceLow = minerUpdateResult.ComputeConfidenceIntervalLow() * 100.0;
int64_t minerMean = minerUpdateResult.MeanPercent();
voteStats.currentMinerThreshold = update->MinerThreshold().GetThreshold(roundNumber);
Expand All @@ -451,7 +451,7 @@ StateInfo UpdateManager::State(enum EUpdate eUpdate, const CBlockIndex *blockInd
// Check Node votes:
{
VoteResult nodeUpdateResult = nodeUpdateVoting.GetVote(pIndexPrev, *update);
voteStats.nodeVoteResult = nodeUpdateResult;
voteStats.nodeUpdateResult = nodeUpdateResult;
int64_t nodeMean = nodeUpdateResult.MeanPercent();
voteStats.currentNodeThreshold = update->NodeThreshold().GetThreshold(roundNumber);
if (nodeMean >= voteStats.currentNodeThreshold) {
Expand Down
4 changes: 2 additions & 2 deletions src/update/update.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@ public :
};

typedef struct VoteStats {
VoteResult nodeVoteResult;
VoteResult minerVoteResult;
VoteResult nodeUpdateResult;
VoteResult minerUpdateResult;
int64_t currentMinerThreshold;
int64_t currentNodeThreshold;
bool nodesApproved;
Expand Down

0 comments on commit ef606d0

Please sign in to comment.