Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
duniter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
typescript
duniter
Commits
a944a8a4
Commit
a944a8a4
authored
6 years ago
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
[enh] sync: wait a bit when the maximum download threshold has been reached
parent
c7941365
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/modules/crawler/lib/sync.ts
+2
-0
2 additions, 0 deletions
app/modules/crawler/lib/sync.ts
with
2 additions
and
0 deletions
app/modules/crawler/lib/sync.ts
+
2
−
0
View file @
a944a8a4
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment