mirror of
https://github.com/monero-project/monero.git
synced 2025-08-16 03:40:34 -04:00
cryptonote_protocol: retry stale spans early
Connections can be dropped by the net_node layer, unbeknownst to cryptonote_protocol, which would then not flush any spans scheduled to that connection, which would cause it to be only downloaded again once it becomes the next span (possibly after a small delay if it had been requested less than 5 seconds ago).
This commit is contained in:
parent
90df52e12f
commit
f57ee382b8
3 changed files with 25 additions and 0 deletions
|
@ -76,6 +76,22 @@ void block_queue::flush_spans(const boost::uuids::uuid &connection_id, bool all)
|
|||
}
|
||||
}
|
||||
|
||||
void block_queue::flush_stale_spans(const std::set<boost::uuids::uuid> &live_connections)
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||
block_map::iterator i = blocks.begin();
|
||||
if (i != blocks.end() && is_blockchain_placeholder(*i))
|
||||
++i;
|
||||
while (i != blocks.end())
|
||||
{
|
||||
block_map::iterator j = i++;
|
||||
if (live_connections.find(j->connection_id) == live_connections.end() && j->blocks.size() == 0)
|
||||
{
|
||||
blocks.erase(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void block_queue::remove_span(uint64_t start_block_height)
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue