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

[enh] #1325 Allow to have up to 10 chunks of advance compared to apply during sync

parent 43fa0c25
No related branches found
No related tags found
No related merge requests found
...@@ -32,6 +32,7 @@ export const CrawlerConstants = { ...@@ -32,6 +32,7 @@ export const CrawlerConstants = {
SANDBOX_CHECK_INTERVAL: 48, // Every 4 hours (288 blocks a day / 24 * 4) SANDBOX_CHECK_INTERVAL: 48, // Every 4 hours (288 blocks a day / 24 * 4)
TEST_PEERS_INTERVAL: 10, // In seconds TEST_PEERS_INTERVAL: 10, // In seconds
SYNC_PEERS_INTERVAL: 3, // Every 3 block average generation time SYNC_PEERS_INTERVAL: 3, // Every 3 block average generation time
SYNC_CHUNKS_IN_ADVANCE: 10, // We want to have that much chunks in advance when syncing
DURATIONS: { DURATIONS: {
TEN_SECONDS: 10, TEN_SECONDS: 10,
......
...@@ -132,13 +132,10 @@ export class DownloadStream extends Duplex { ...@@ -132,13 +132,10 @@ export class DownloadStream extends Duplex {
delete this.chunks[this.currentChunkNumber] delete this.chunks[this.currentChunkNumber]
// Let's start the download of next chunk // Let's start the download of next chunk
this.currentChunkNumber++ this.currentChunkNumber++
this.downloadChunk(this.currentChunkNumber) let p = this.downloadChunk(this.currentChunkNumber)
.then(() => this.downloadChunk(this.currentChunkNumber + 1)) for (let i = 1; i <= CrawlerConstants.SYNC_CHUNKS_IN_ADVANCE; i++) {
.then(() => this.downloadChunk(this.currentChunkNumber + 2)) p = p.then(() => this.downloadChunk(this.currentChunkNumber + i))
.then(() => this.downloadChunk(this.currentChunkNumber + 3)) }
.then(() => this.downloadChunk(this.currentChunkNumber + 4))
.then(() => this.downloadChunk(this.currentChunkNumber + 5))
.then(() => this.downloadChunk(this.currentChunkNumber + 6))
} }
else { else {
// We don't have it yet // We don't have it yet
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment