Skip to content

Commit

Permalink
Don't return earliest height for unknown forks.
Browse files Browse the repository at this point in the history
  • Loading branch information
fireice-uk committed Aug 10, 2018
1 parent a697e2a commit 12bad0a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/cryptonote_basic/hardfork.cpp
Expand Up @@ -413,14 +413,14 @@ uint8_t HardFork::get_ideal_version(uint64_t height) const
return original_version;
}

uint64_t HardFork::get_earliest_ideal_height_for_version(uint8_t version) const
uint64_t HardFork::get_height_for_version(uint8_t version) const
{
for(unsigned int n = heights.size() - 1; n > 0; --n)
for(const Params& fork : heights)
{
if(heights[n].version <= version)
return heights[n].height;
if(fork.version == version)
return fork.height;
}
return 0;
return uint64_t(-1);
}

uint8_t HardFork::get_next_version() const
Expand Down Expand Up @@ -449,7 +449,7 @@ bool HardFork::get_voting_info(uint8_t version, uint32_t &window, uint32_t &vote
votes += last_versions[n];
threshold = (window * heights[current_fork_index].threshold + 99) / 100;
//assert((votes >= threshold) == enabled);
earliest_height = get_earliest_ideal_height_for_version(version);
earliest_height = get_height_for_version(version);
voting = heights.back().version;
return enabled;
}
5 changes: 3 additions & 2 deletions src/cryptonote_basic/hardfork.h
Expand Up @@ -213,9 +213,10 @@ class HardFork
uint8_t get_current_version_num() const;

/**
* @brief returns the earliest block a given version may activate
* @brief returns the earliest block a known version may activate
* @return height or uint64_t(-1) if the version is not known
*/
uint64_t get_earliest_ideal_height_for_version(uint8_t version) const;
uint64_t get_height_for_version(uint8_t version) const;

/**
* @brief returns information about current voting state
Expand Down

0 comments on commit 12bad0a

Please sign in to comment.