mirror of
https://github.com/monero-project/monero.git
synced 2024-12-23 12:09:54 +00:00
Merge pull request #3726
b5cb1bc
blockchain: avoid exception if asked for a block we do not have (moneromooo-monero)
This commit is contained in:
commit
b3363e8e0a
1 changed files with 11 additions and 8 deletions
|
@ -2095,16 +2095,19 @@ bool Blockchain::get_blocks(const t_ids_container& block_ids, t_blocks_container
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
blocks.push_back(std::make_pair(m_db->get_block_blob(block_hash), block()));
|
uint64_t height = 0;
|
||||||
if (!parse_and_validate_block_from_blob(blocks.back().first, blocks.back().second))
|
if (m_db->block_exists(block_hash, &height))
|
||||||
{
|
{
|
||||||
LOG_ERROR("Invalid block");
|
blocks.push_back(std::make_pair(m_db->get_block_blob_from_height(height), block()));
|
||||||
return false;
|
if (!parse_and_validate_block_from_blob(blocks.back().first, blocks.back().second))
|
||||||
|
{
|
||||||
|
LOG_ERROR("Invalid block: " << block_hash);
|
||||||
|
blocks.pop_back();
|
||||||
|
missed_bs.push_back(block_hash);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
catch (const BLOCK_DNE& e)
|
missed_bs.push_back(block_hash);
|
||||||
{
|
|
||||||
missed_bs.push_back(block_hash);
|
|
||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue