diff options
author | Neozaru <neozaru@mailoo.org> | 2014-06-04 22:50:13 +0200 |
---|---|---|
committer | Neozaru <neozaru@mailoo.org> | 2014-06-04 22:50:13 +0200 |
commit | 7fea5645e2e9da312d2b02a1e22087f4b9aba1ce (patch) | |
tree | 668c6453431fc8042332ded91eb78da5315036d6 /src/crypto | |
parent | Merge pull request #2 from monero-project/master (diff) | |
download | monero-7fea5645e2e9da312d2b02a1e22087f4b9aba1ce.tar.xz |
'getinfo' daemon HTTP-RPC returns 'target_height' for progress estimations
Diffstat (limited to '')
-rw-r--r-- | src/cryptonote_core/cryptonote_core.cpp | 10 | ||||
-rw-r--r-- | src/cryptonote_core/cryptonote_core.h | 5 | ||||
-rw-r--r-- | src/cryptonote_protocol/cryptonote_protocol_handler.inl | 5 |
3 files changed, 19 insertions, 1 deletions
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index b6bfa09c8..b2389fce2 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -28,7 +28,8 @@ namespace cryptonote m_blockchain_storage(m_mempool), m_miner(this), m_miner_address(boost::value_initialized<account_public_address>()), - m_starter_message_showed(false) + m_starter_message_showed(false), + m_target_blockchain_height(0) { set_cryptonote_protocol(pprotocol); } @@ -516,4 +517,11 @@ namespace cryptonote return true; } //----------------------------------------------------------------------------------------------- + void core::set_target_blockchain_height(uint64_t target_blockchain_height) { + m_target_blockchain_height = target_blockchain_height; + } + //----------------------------------------------------------------------------------------------- + uint64_t core::get_target_blockchain_height() const { + return m_target_blockchain_height; + } } diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h index cde52d5a2..7ef0f8b1d 100644 --- a/src/cryptonote_core/cryptonote_core.h +++ b/src/cryptonote_core/cryptonote_core.h @@ -90,6 +90,9 @@ namespace cryptonote void print_blockchain_outs(const std::string& file); void on_synchronized(); + void set_target_blockchain_height(uint64_t target_blockchain_height); + uint64_t get_target_blockchain_height() const; + private: bool add_new_tx(const transaction& tx, const crypto::hash& tx_hash, const crypto::hash& tx_prefix_hash, size_t blob_size, tx_verification_context& tvc, bool keeped_by_block); bool add_new_tx(const transaction& tx, tx_verification_context& tvc, bool keeped_by_block); @@ -124,6 +127,8 @@ namespace cryptonote epee::math_helper::once_a_time_seconds<60*60*12, false> m_store_blockchain_interval; friend class tx_validate_inputs; std::atomic<bool> m_starter_message_showed; + + uint64_t m_target_blockchain_height; }; } diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl index 2584f1097..b74a81586 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl +++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl @@ -108,6 +108,11 @@ namespace cryptonote return true; } + /* As I don't know if accessing hshd from core could be a good practice, + I prefer pushing target height to the core at the same time it is pushed to the user. + Nz. */ + m_core.set_target_blockchain_height(hshd.current_height); + int64_t diff = static_cast<int64_t>(hshd.current_height) - static_cast<int64_t>(m_core.get_current_blockchain_height()); LOG_PRINT_CCONTEXT_YELLOW("Sync data returned unknown top block: " << m_core.get_current_blockchain_height() << " -> " << hshd.current_height << " [" << std::abs(diff) << " blocks (" << diff / (24 * 60 * 60 / DIFFICULTY_TARGET) << " days) " |