save some database calls when getting top block hash and height

This commit is contained in:
moneromooo-monero
2018-11-20 20:19:39 +00:00
parent 9827880877
commit 79b4e9f377
7 changed files with 49 additions and 31 deletions
+3 -1
View File
@@ -2582,11 +2582,13 @@ std::vector<crypto::hash> BlockchainLMDB::get_hashes_range(const uint64_t& h1, c
return v;
}
crypto::hash BlockchainLMDB::top_block_hash() const
crypto::hash BlockchainLMDB::top_block_hash(uint64_t *block_height) const
{
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
check_open();
uint64_t m_height = height();
if (block_height)
*block_height = m_height - 1;
if (m_height != 0)
{
return get_block_hash_from_height(m_height - 1);
+1 -1
View File
@@ -233,7 +233,7 @@ public:
virtual std::vector<crypto::hash> get_hashes_range(const uint64_t& h1, const uint64_t& h2) const;
virtual crypto::hash top_block_hash() const;
virtual crypto::hash top_block_hash(uint64_t *block_height = NULL) const;
virtual block get_top_block() const;