aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core/blockchain.cpp
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2018-06-16 14:02:56 -0500
committerluigi1111 <luigi1111w@gmail.com>2018-06-16 14:02:56 -0500
commitb3363e8e0ae7abd0d6f4ac0be925ec2486f5e2d0 (patch)
tree48096cf36c395e5c442ea432e56ea0fa2c5c91a5 /src/cryptonote_core/blockchain.cpp
parentMerge pull request #3725 (diff)
parentblockchain: avoid exception if asked for a block we do not have (diff)
downloadmonero-b3363e8e0ae7abd0d6f4ac0be925ec2486f5e2d0.tar.xz
Merge pull request #3726
b5cb1bc blockchain: avoid exception if asked for a block we do not have (moneromooo-monero)
Diffstat (limited to 'src/cryptonote_core/blockchain.cpp')
-rw-r--r--src/cryptonote_core/blockchain.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index a8565d3f5..ae2b47570 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -2095,16 +2095,19 @@ bool Blockchain::get_blocks(const t_ids_container& block_ids, t_blocks_container
{
try
{
- blocks.push_back(std::make_pair(m_db->get_block_blob(block_hash), block()));
- if (!parse_and_validate_block_from_blob(blocks.back().first, blocks.back().second))
+ uint64_t height = 0;
+ if (m_db->block_exists(block_hash, &height))
{
- LOG_ERROR("Invalid block");
- return false;
+ blocks.push_back(std::make_pair(m_db->get_block_blob_from_height(height), block()));
+ 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);
+ }
}
- }
- catch (const BLOCK_DNE& e)
- {
- missed_bs.push_back(block_hash);
+ else
+ missed_bs.push_back(block_hash);
}
catch (const std::exception& e)
{