diff options
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r-- | src/cryptonote_core/blockchain.cpp | 1 | ||||
-rw-r--r-- | src/cryptonote_core/blockchain.h | 10 | ||||
-rw-r--r-- | src/cryptonote_core/cryptonote_core.cpp | 5 | ||||
-rw-r--r-- | src/cryptonote_core/cryptonote_core.h | 7 |
4 files changed, 23 insertions, 0 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 61ddff3d0..14a990131 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -2038,6 +2038,7 @@ bool Blockchain::find_blockchain_supplement(const std::list<crypto::hash>& qbloc { resp.m_block_ids.push_back(m_db->get_block_hash_from_height(i)); } + resp.cumulative_difficulty = m_db->get_block_cumulative_difficulty(m_db->height() - 1); m_db->block_txn_stop(); return true; } diff --git a/src/cryptonote_core/blockchain.h b/src/cryptonote_core/blockchain.h index 7137f50a7..7fa78584b 100644 --- a/src/cryptonote_core/blockchain.h +++ b/src/cryptonote_core/blockchain.h @@ -831,6 +831,16 @@ namespace cryptonote * * @return a reference to the BlockchainDB instance */ + const BlockchainDB& get_db() const + { + return *m_db; + } + + /** + * @brief get a reference to the BlockchainDB in use by Blockchain + * + * @return a reference to the BlockchainDB instance + */ BlockchainDB& get_db() { return *m_db; diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index ac2d3023a..430d66e21 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -1110,6 +1110,11 @@ namespace cryptonote return m_blockchain_storage.get_tail_id(); } //----------------------------------------------------------------------------------------------- + difficulty_type core::get_block_cumulative_difficulty(uint64_t height) const + { + return m_blockchain_storage.get_db().get_block_cumulative_difficulty(height); + } + //----------------------------------------------------------------------------------------------- size_t core::get_pool_transactions_count() const { return m_mempool.get_transactions_count(); diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h index 63d3cd16d..3c66d772d 100644 --- a/src/cryptonote_core/cryptonote_core.h +++ b/src/cryptonote_core/cryptonote_core.h @@ -521,6 +521,13 @@ namespace cryptonote crypto::hash get_tail_id() const; /** + * @copydoc Blockchain::get_block_cumulative_difficulty + * + * @note see Blockchain::get_block_cumulative_difficulty + */ + difficulty_type get_block_cumulative_difficulty(uint64_t height) const; + + /** * @copydoc Blockchain::get_random_outs_for_amounts * * @note see Blockchain::get_random_outs_for_amounts |