mirror of
https://github.com/monero-project/monero.git
synced 2025-07-23 06:00:42 -04:00
Allow the wallet to access hard fork information
And make it change behavior slightly when close/after first hard fork
This commit is contained in:
parent
760331b427
commit
8ea7af1ba3
8 changed files with 63 additions and 8 deletions
|
@ -3173,9 +3173,9 @@ HardFork::State Blockchain::get_hard_fork_state() const
|
|||
return m_hardfork->get_state();
|
||||
}
|
||||
|
||||
bool Blockchain::get_hard_fork_voting_info(uint8_t version, uint32_t &window, uint32_t &votes, uint32_t &threshold, uint8_t &voting) const
|
||||
bool Blockchain::get_hard_fork_voting_info(uint8_t version, uint32_t &window, uint32_t &votes, uint32_t &threshold, uint64_t &earliest_height, uint8_t &voting) const
|
||||
{
|
||||
return m_hardfork->get_voting_info(version, window, votes, threshold, voting);
|
||||
return m_hardfork->get_voting_info(version, window, votes, threshold, earliest_height, voting);
|
||||
}
|
||||
|
||||
bool Blockchain::for_all_key_images(std::function<bool(const crypto::key_image&)> f) const
|
||||
|
|
|
@ -162,7 +162,7 @@ namespace cryptonote
|
|||
uint8_t get_ideal_hard_fork_version() const { return m_hardfork->get_ideal_version(); }
|
||||
uint8_t get_ideal_hard_fork_version(uint64_t height) const { return m_hardfork->get_ideal_version(height); }
|
||||
|
||||
bool get_hard_fork_voting_info(uint8_t version, uint32_t &window, uint32_t &votes, uint32_t &threshold, uint8_t &voting) const;
|
||||
bool get_hard_fork_voting_info(uint8_t version, uint32_t &window, uint32_t &votes, uint32_t &threshold, uint64_t &earliest_height, uint8_t &voting) const;
|
||||
|
||||
bool for_all_key_images(std::function<bool(const crypto::key_image&)>) const;
|
||||
bool for_all_blocks(std::function<bool(uint64_t, const crypto::hash&, const block&)>) const;
|
||||
|
|
|
@ -355,7 +355,16 @@ uint8_t HardFork::get_ideal_version(uint64_t height) const
|
|||
return original_version;
|
||||
}
|
||||
|
||||
bool HardFork::get_voting_info(uint8_t version, uint32_t &window, uint32_t &votes, uint32_t &threshold, uint8_t &voting) const
|
||||
uint64_t HardFork::get_earliest_ideal_height_for_version(uint8_t version) const
|
||||
{
|
||||
for (unsigned int n = heights.size() - 1; n > 0; --n) {
|
||||
if (heights[n].version <= version)
|
||||
return heights[n].height;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool HardFork::get_voting_info(uint8_t version, uint32_t &window, uint32_t &votes, uint32_t &threshold, uint64_t &earliest_height, uint8_t &voting) const
|
||||
{
|
||||
CRITICAL_REGION_LOCAL(lock);
|
||||
|
||||
|
@ -367,6 +376,7 @@ bool HardFork::get_voting_info(uint8_t version, uint32_t &window, uint32_t &vote
|
|||
votes += last_versions[n];
|
||||
threshold = (window * heights[current_version].threshold + 99) / 100;
|
||||
assert((votes >= threshold) == enabled);
|
||||
earliest_height = get_earliest_ideal_height_for_version(version);
|
||||
voting = heights.back().version;
|
||||
return enabled;
|
||||
}
|
||||
|
|
|
@ -183,6 +183,11 @@ namespace cryptonote
|
|||
*/
|
||||
uint8_t get_current_version() const;
|
||||
|
||||
/**
|
||||
* @brief returns the earliest block a given version may activate
|
||||
*/
|
||||
uint64_t get_earliest_ideal_height_for_version(uint8_t version) const;
|
||||
|
||||
/**
|
||||
* @brief returns information about current voting state
|
||||
*
|
||||
|
@ -193,8 +198,9 @@ namespace cryptonote
|
|||
* @param window the number of blocks considered in voting
|
||||
* @param votes number of votes for next version
|
||||
* @param threshold number of votes needed to switch to next version
|
||||
* @param earliest_height earliest height at which the version can take effect
|
||||
*/
|
||||
bool get_voting_info(uint8_t version, uint32_t &window, uint32_t &votes, uint32_t &threshold, uint8_t &voting) const;
|
||||
bool get_voting_info(uint8_t version, uint32_t &window, uint32_t &votes, uint32_t &threshold, uint64_t &earliest_height, uint8_t &voting) const;
|
||||
|
||||
/**
|
||||
* @brief returns the size of the voting window in blocks
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue