mirror of
https://github.com/Cuprate/cuprate.git
synced 2025-03-12 09:29:11 +00:00
fix stopping the block downloader
This commit is contained in:
parent
bd1b7ff6c5
commit
7d33ab25b4
1 changed files with 9 additions and 4 deletions
|
@ -468,7 +468,7 @@ where
|
|||
client: ClientPoolDropGuard<N>,
|
||||
) -> Option<ClientPoolDropGuard<N>> {
|
||||
if self.chain_entry_task.len() < 2
|
||||
&& self.amount_of_empty_chain_entries < 2
|
||||
&& self.amount_of_empty_chain_entries <= 5
|
||||
&& chain_tracker.block_requests_queued(self.amount_of_blocks_to_request) < 500
|
||||
&& chain_tracker.should_ask_for_next_chain_entry(&client.info.pruning_seed)
|
||||
{
|
||||
|
@ -666,11 +666,19 @@ where
|
|||
tokio::select! {
|
||||
_ = check_client_pool_interval.tick() => {
|
||||
self.check_for_free_clients(&mut chain_tracker).await?;
|
||||
|
||||
if self.block_download_tasks.is_empty() && self.amount_of_empty_chain_entries > 5 {
|
||||
return Ok(())
|
||||
}
|
||||
}
|
||||
Some(res) = self.block_download_tasks.join_next() => {
|
||||
let (start_height, res) = res.expect("Download batch future panicked");
|
||||
|
||||
self.handle_download_batch_res(start_height, res, &mut chain_tracker).await?;
|
||||
|
||||
if self.block_download_tasks.is_empty() && self.amount_of_empty_chain_entries > 5 {
|
||||
return Ok(())
|
||||
}
|
||||
}
|
||||
Some(Ok(res)) = self.chain_entry_task.join_next() => {
|
||||
match res {
|
||||
|
@ -693,9 +701,6 @@ where
|
|||
Err(_) => self.amount_of_empty_chain_entries += 1
|
||||
}
|
||||
}
|
||||
else => {
|
||||
self.check_for_free_clients(&mut chain_tracker).await?;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue