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:
moneromooo-monero 2017-07-11 21:48:54 +01:00
parent 90df52e12f
commit f57ee382b8
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
3 changed files with 25 additions and 0 deletions

View file

@ -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);