Skip to content
Snippets Groups Projects
Commit a944a8a4 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

[enh] sync: wait a bit when the maximum download threshold has been reached

parent c7941365
Branches
No related tags found
No related merge requests found
...@@ -651,6 +651,7 @@ class P2PDownloader { ...@@ -651,6 +651,7 @@ class P2PDownloader {
private PARALLEL_PER_CHUNK = 1; private PARALLEL_PER_CHUNK = 1;
private MAX_DELAY_PER_DOWNLOAD = 15000; private MAX_DELAY_PER_DOWNLOAD = 15000;
private WAIT_DELAY_WHEN_MAX_DOWNLOAD_IS_REACHED = 3000;
private NO_NODES_AVAILABLE = "No node available for download"; private NO_NODES_AVAILABLE = "No node available for download";
private TOO_LONG_TIME_DOWNLOAD:string private TOO_LONG_TIME_DOWNLOAD:string
private nbBlocksToDownload:number private nbBlocksToDownload:number
...@@ -838,6 +839,7 @@ class P2PDownloader { ...@@ -838,6 +839,7 @@ class P2PDownloader {
// We remove the nodes impossible to reach (timeout) // We remove the nodes impossible to reach (timeout)
let withGoodDelays = Underscore.filter(candidates, (c:any) => c.tta <= this.MAX_DELAY_PER_DOWNLOAD); let withGoodDelays = Underscore.filter(candidates, (c:any) => c.tta <= this.MAX_DELAY_PER_DOWNLOAD);
if (withGoodDelays.length === 0) { if (withGoodDelays.length === 0) {
await new Promise(res => setTimeout(res, this.WAIT_DELAY_WHEN_MAX_DOWNLOAD_IS_REACHED)) // We wait a bit before continuing the downloads
// No node can be reached, we can try to lower the number of nodes on which we download // No node can be reached, we can try to lower the number of nodes on which we download
this.downloadSlots = Math.floor(this.downloadSlots / 2); this.downloadSlots = Math.floor(this.downloadSlots / 2);
// We reinitialize the nodes // We reinitialize the nodes
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment