From d4e27a27cbfa5f787e967c920eb9fc878c9bd0e0 Mon Sep 17 00:00:00 2001 From: SChernykh Date: Wed, 17 Aug 2022 16:44:40 +0200 Subject: [PATCH] Tweaked SideChain::get_missing_blocks() --- src/side_chain.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/side_chain.cpp b/src/side_chain.cpp index 199fd57..614ce96 100644 --- a/src/side_chain.cpp +++ b/src/side_chain.cpp @@ -1904,9 +1904,18 @@ void SideChain::get_missing_blocks(std::vector& missing_blocks) const missing_blocks.push_back(b.second->m_parent); } + int num_missing_uncles = 0; + for (const hash& h : b.second->m_uncles) { if (!h.empty() && (m_blocksById.find(h) == m_blocksById.end())) { missing_blocks.push_back(h); + + // Get no more than 2 first missing uncles at a time from each block + // Blocks with more than 2 uncles are very rare and they will be processed in several steps + ++num_missing_uncles; + if (num_missing_uncles >= 2) { + break; + } } } }