mirror of
https://github.com/monero-project/monero.git
synced 2024-12-23 12:09:54 +00:00
blockchain: fix block rate check for empty blockchains
This commit is contained in:
parent
6bc0c7e685
commit
b8342dd52c
1 changed files with 3 additions and 1 deletions
|
@ -918,8 +918,10 @@ difficulty_type Blockchain::get_difficulty_for_next_block()
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
std::vector<time_t> Blockchain::get_last_block_timestamps(unsigned int blocks) const
|
std::vector<time_t> Blockchain::get_last_block_timestamps(unsigned int blocks) const
|
||||||
{
|
{
|
||||||
std::vector<time_t> timestamps(blocks);
|
|
||||||
uint64_t height = m_db->height();
|
uint64_t height = m_db->height();
|
||||||
|
if (blocks > height)
|
||||||
|
blocks = height;
|
||||||
|
std::vector<time_t> timestamps(blocks);
|
||||||
while (blocks--)
|
while (blocks--)
|
||||||
timestamps[blocks] = m_db->get_block_timestamp(height - blocks - 1);
|
timestamps[blocks] = m_db->get_block_timestamp(height - blocks - 1);
|
||||||
return timestamps;
|
return timestamps;
|
||||||
|
|
Loading…
Reference in a new issue