implementation of yield_info function

This commit is contained in:
Some Random Crypto Guy
2024-05-14 14:23:31 +01:00
parent b0ce6d2969
commit ae28c7a900
12 changed files with 179 additions and 25 deletions
+21
View File
@@ -4393,6 +4393,27 @@ bool Blockchain::validate_ybi_cache()
return true;
}
//------------------------------------------------------------------
bool Blockchain::get_ybi_cache(std::map<uint64_t, yield_block_info>& ybi_cache)
{
LOG_PRINT_L3("Blockchain::" << __func__);
// Clear the provided container
ybi_cache.clear();
// Make sure the cache is fully populated and up to date
if (!validate_ybi_cache()) {
LOG_PRINT_L1("yield information cache is invalid - rebuilding cache");
if (!rebuild_ybi_cache()) {
LOG_ERROR("Failed to rebuild yield information cache - aborting");
return false;
}
}
// Copy the cache
ybi_cache = m_yield_block_info_cache;
return true;
}
//------------------------------------------------------------------
bool Blockchain::get_ybi_entry(const uint64_t height, cryptonote::yield_block_info& ybi)
{
LOG_PRINT_L3("Blockchain::" << __func__);
+11
View File
@@ -1154,6 +1154,17 @@ namespace cryptonote
*/
bool calculate_yield_payouts(const uint64_t start_height, std::vector<std::pair<yield_tx_info, uint64_t>>& yield_payouts);
/**
* @brief get the complete YBI cache
*
* Retrieve the YBI local cache.
* If the cache is out of date, the cache will (attempt to) be rebuilt
* before being returned.
*
* @return TRUE if the call is successful, FALSE otherwise
*/
bool get_ybi_cache(std::map<uint64_t, yield_block_info>& ybi_cache);
/**
* @brief get the YBI entry for a particular height from the cache
*