aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortobtoht <tob@featherwallet.org>2025-11-11 22:42:07 +0000
committertobtoht <tob@featherwallet.org>2025-11-11 22:42:07 +0000
commit68732126e957723d3b7f648447877bf4cab4fc37 (patch)
tree69855d3a6fbda83951a1d2675547f582303a9dc3
parent64f230d63adff7b544e8f2ba080ead4b7595ee04 (diff)
parentdafecd0addb171751efd31fea417d36da84e5efe (diff)
downloadmonzero-core-68732126e957723d3b7f648447877bf4cab4fc37.tar.gz
monzero-core-68732126e957723d3b7f648447877bf4cab4fc37.tar.xz
monzero-core-68732126e957723d3b7f648447877bf4cab4fc37.zip
Merge pull request #10202
dafecd0 cryptonote_protocol: accurate next_needed_height when there is an overlap (0xFFFC0000)
-rw-r--r--src/cryptonote_protocol/block_queue.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/cryptonote_protocol/block_queue.cpp b/src/cryptonote_protocol/block_queue.cpp
index f8962df06..7eadb72f2 100644
--- a/src/cryptonote_protocol/block_queue.cpp
+++ b/src/cryptonote_protocol/block_queue.cpp
@@ -153,18 +153,26 @@ uint64_t block_queue::get_next_needed_height(uint64_t blockchain_height) const
boost::unique_lock<boost::recursive_mutex> lock(mutex);
if (blocks.empty())
return blockchain_height;
- uint64_t last_needed_height = blockchain_height;
- bool first = true;
+
+ uint64_t covered_until = blockchain_height;
+
for (const auto &span: blocks)
{
- if (span.start_block_height + span.nblocks - 1 < blockchain_height)
+ // Ignore spans entirely below current chain height
+ const uint64_t span_end = span.start_block_height + span.nblocks - 1;
+ if (span_end < blockchain_height)
continue;
- if (span.start_block_height != last_needed_height || (first && span.blocks.empty()))
- return last_needed_height;
- last_needed_height = span.start_block_height + span.nblocks;
- first = false;
+
+ // If this span starts after what we already have/scheduled, we found the first gap
+ if (span.start_block_height > covered_until)
+ return covered_until;
+
+ // This span overlaps or is adjacent; extend coverage regardless of filled/scheduled
+ if (span.start_block_height <= covered_until)
+ covered_until = std::max(covered_until, span.start_block_height + span.nblocks);
}
- return last_needed_height;
+
+ return covered_until;
}
void block_queue::print() const