aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_basic/hardfork.cpp
diff options
context:
space:
mode:
authorstoffu <stoffu@protonmail.ch>2018-03-20 11:09:58 +0900
committerstoffu <stoffu@protonmail.ch>2018-05-30 09:49:57 +0900
commit98cf62cc45d6edd8d35f326ba0736728e624d5fd (patch)
tree97062951dc5155191b94e6bf4788caa4cb5b45f8 /src/cryptonote_basic/hardfork.cpp
parentunit_tests/hardfork: add tests for check_for_height() (diff)
downloadmonero-98cf62cc45d6edd8d35f326ba0736728e624d5fd.tar.xz
hardfork: fix get_next_version()
Diffstat (limited to 'src/cryptonote_basic/hardfork.cpp')
-rw-r--r--src/cryptonote_basic/hardfork.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/cryptonote_basic/hardfork.cpp b/src/cryptonote_basic/hardfork.cpp
index aa6746304..f05b25901 100644
--- a/src/cryptonote_basic/hardfork.cpp
+++ b/src/cryptonote_basic/hardfork.cpp
@@ -394,9 +394,9 @@ uint8_t HardFork::get_next_version() const
{
CRITICAL_REGION_LOCAL(lock);
uint64_t height = db.height();
- for (unsigned int n = heights.size() - 1; n > 0; --n) {
- if (height >= heights[n].height) {
- return heights[n < heights.size() - 1 ? n + 1 : n].version;
+ for (auto i = heights.rbegin(); i != heights.rend(); ++i) {
+ if (height >= i->height) {
+ return (i == heights.rbegin() ? i : (i - 1))->version;
}
}
return original_version;