From 3f2970fadbe2d4dc7057d0c3b83faa93b8622bde Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sat, 19 Dec 2015 14:47:37 +0000 Subject: Add missing semicolons after log statements --- src/cryptonote_core/blockchain.cpp | 6 +++--- src/cryptonote_core/miner.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/cryptonote_core') diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 45ddc45e9..55571f57b 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -394,7 +394,7 @@ bool Blockchain::deinit() { LOG_PRINT_L3("Blockchain::" << __func__); - LOG_PRINT_L0("Closing IO Service.") + LOG_PRINT_L0("Closing IO Service."); // stop async service m_async_work_idle.reset(); m_async_pool.join_all(); @@ -2898,7 +2898,7 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::listtop_block_hash(); if (block.prev_id != tophash) { - LOG_PRINT_L1("Skipping prepare blocks. New blocks don't belong to chain.") + LOG_PRINT_L1("Skipping prepare blocks. New blocks don't belong to chain."); return true; } } @@ -2958,7 +2958,7 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::list Date: Sat, 19 Dec 2015 14:52:30 +0000 Subject: Allow the wallet to access hard fork information And make it change behavior slightly when close/after first hard fork --- src/cryptonote_core/blockchain.cpp | 4 ++-- src/cryptonote_core/blockchain.h | 2 +- src/cryptonote_core/hardfork.cpp | 12 +++++++++++- src/cryptonote_core/hardfork.h | 8 +++++++- 4 files changed, 21 insertions(+), 5 deletions(-) (limited to 'src/cryptonote_core') diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 55571f57b..badccd06f 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -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 f) const diff --git a/src/cryptonote_core/blockchain.h b/src/cryptonote_core/blockchain.h index e8f5a7e5b..1efc4e394 100644 --- a/src/cryptonote_core/blockchain.h +++ b/src/cryptonote_core/blockchain.h @@ -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) const; bool for_all_blocks(std::function) const; diff --git a/src/cryptonote_core/hardfork.cpp b/src/cryptonote_core/hardfork.cpp index 550047289..9bd4a337c 100644 --- a/src/cryptonote_core/hardfork.cpp +++ b/src/cryptonote_core/hardfork.cpp @@ -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; } diff --git a/src/cryptonote_core/hardfork.h b/src/cryptonote_core/hardfork.h index 6d2a3c55b..d2f701799 100644 --- a/src/cryptonote_core/hardfork.h +++ b/src/cryptonote_core/hardfork.h @@ -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 -- cgit v1.2.3