src: dynamic span, to calculate span limit dynamically

Co-authored-by: nahuhh
    - jberman review
    - cryptonote_protocol: don't arbitrarily download 1000 blocks ahead
    - further restrict `proceed` to require `queue_proceed` in all cases.
      ensure queue_proceed is true if we need the next block, even if we
      already exceed the span and size limits

cryptonote_protocol: improved logging + const usage in span downloader
This commit is contained in:
Navid Rahimi
2026-02-04 08:54:23 +00:00
co-authored by nahuhh
parent 20ef991839
commit 508b6ee8fb
5 changed files with 70 additions and 24 deletions
+7
View File
@@ -83,6 +83,7 @@ void block_queue::flush_spans(const boost::uuids::uuid &connection_id, bool all)
void block_queue::erase_block(block_map::iterator j)
{
MDEBUG("Erasing span starting from block " << j->start_block_height);
CHECK_AND_ASSERT_THROW_MES(j != blocks.end(), "Invalid iterator");
for (const crypto::hash &h: j->hashes)
{
@@ -152,7 +153,10 @@ uint64_t block_queue::get_next_needed_height(uint64_t blockchain_height) const
{
boost::unique_lock<boost::recursive_mutex> lock(mutex);
if (blocks.empty())
{
MDEBUG("Span queue is empty");
return blockchain_height;
}
uint64_t covered_until = blockchain_height;
@@ -165,7 +169,10 @@ uint64_t block_queue::get_next_needed_height(uint64_t blockchain_height) const
// If this span starts after what we already have/scheduled, we found the first gap
if (span.start_block_height > covered_until)
{
MDEBUG("Found gap in the span queue from " << covered_until << " to " << span.start_block_height);
return covered_until;
}
// This span overlaps or is adjacent; extend coverage regardless of filled/scheduled
if (span.start_block_height <= covered_until)