aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_basic
diff options
context:
space:
mode:
authorstoffu <stoffu@protonmail.ch>2018-03-20 09:52:16 +0900
committerstoffu <stoffu@protonmail.ch>2018-05-30 09:49:52 +0900
commita79fc219b75173d9257ecebb604d1ec24c9f1c2d (patch)
tree6ddae269b0ebf76546aeefba8f25a2e860fc65a5 /src/cryptonote_basic
parentMerge pull request #3251 (diff)
downloadmonero-a79fc219b75173d9257ecebb604d1ec24c9f1c2d.tar.xz
hardfork: fix get_earliest_ideal_height_for_version() to support non-existent versions
Diffstat (limited to 'src/cryptonote_basic')
-rw-r--r--src/cryptonote_basic/hardfork.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/cryptonote_basic/hardfork.cpp b/src/cryptonote_basic/hardfork.cpp
index 95f1ecab9..aa6746304 100644
--- a/src/cryptonote_basic/hardfork.cpp
+++ b/src/cryptonote_basic/hardfork.cpp
@@ -379,11 +379,15 @@ uint8_t HardFork::get_ideal_version(uint64_t height) 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;
+ uint64_t height = std::numeric_limits<uint64_t>::max();
+ for (auto i = heights.rbegin(); i != heights.rend(); ++i) {
+ if (i->version >= version) {
+ height = i->height;
+ } else {
+ break;
+ }
}
- return 0;
+ return height;
}
uint8_t HardFork::get_next_version() const