mirror of
https://github.com/monero-project/monero.git
synced 2025-08-12 06:10:24 -04:00
Add an RPC call and daemon command to get info on hard fork voting
This commit is contained in:
parent
d06713199e
commit
e546f3724a
13 changed files with 169 additions and 5 deletions
|
@ -135,7 +135,7 @@ void HardFork::init()
|
|||
starting[n] = 0;
|
||||
checkpoints.clear();
|
||||
current_fork_index = 0;
|
||||
vote_threshold = (unsigned int)ceilf(max_history * threshold_percent / 100.0f);
|
||||
vote_threshold = (uint32_t)ceilf(max_history * threshold_percent / 100.0f);
|
||||
}
|
||||
|
||||
bool HardFork::reorganize_from_block_height(const cryptonote::BlockchainDB *db, uint64_t height)
|
||||
|
@ -186,7 +186,7 @@ bool HardFork::reorganize_from_chain_height(const cryptonote::BlockchainDB *db,
|
|||
int HardFork::get_voted_fork_index(uint64_t height) const
|
||||
{
|
||||
CRITICAL_REGION_LOCAL(lock);
|
||||
unsigned int accumulated_votes = 0;
|
||||
uint32_t accumulated_votes = 0;
|
||||
for (unsigned int n = heights.size() - 1; n > current_fork_index; --n) {
|
||||
uint8_t v = heights[n].version;
|
||||
accumulated_votes += last_versions[v];
|
||||
|
@ -247,6 +247,22 @@ uint8_t HardFork::get_ideal_version() const
|
|||
return heights.back().version;
|
||||
}
|
||||
|
||||
bool HardFork::get_voting_info(uint8_t version, uint32_t &window, uint32_t &votes, uint32_t &threshold, uint8_t &voting) const
|
||||
{
|
||||
CRITICAL_REGION_LOCAL(lock);
|
||||
|
||||
const uint8_t current_version = heights[current_fork_index].version;
|
||||
const bool enabled = current_version >= version;
|
||||
window = versions.size();
|
||||
votes = 0;
|
||||
for (size_t n = version; n < 256; ++n)
|
||||
votes += last_versions[n];
|
||||
threshold = vote_threshold;
|
||||
assert((votes >= threshold) == enabled);
|
||||
voting = heights.back().version;
|
||||
return enabled;
|
||||
}
|
||||
|
||||
template<class archive_t>
|
||||
void HardFork::serialize(archive_t & ar, const unsigned int version)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue