From cf04e781b4fb87f6f80339de0a20a2576b01eed4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Moreau?= <cem.moreau@gmail.com> Date: Sun, 25 Feb 2018 12:45:21 +0100 Subject: [PATCH] Revert "Debug why sync fails on G1-Test" This reverts commit 86b69e0 --- app/lib/computation/QuickSync.ts | 3 --- app/modules/crawler/lib/sync.ts | 18 +++++------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/app/lib/computation/QuickSync.ts b/app/lib/computation/QuickSync.ts index 27a182f05..5d8853884 100644 --- a/app/lib/computation/QuickSync.ts +++ b/app/lib/computation/QuickSync.ts @@ -179,9 +179,6 @@ export class QuickSynchronizer { } })) - if (sync_cindex.length) sync_cindex.map(c => console.log(c)) - if (sync_mindex.length) sync_mindex.map(c => console.log(c)) - if (sync_iindex.length) sync_iindex.map(c => console.log(c)) // Flush the INDEX (not bindex, which is particular) await this.dal.mindexDAL.insertBatch(sync_mindex); await this.dal.iindexDAL.insertBatch(sync_iindex); diff --git a/app/modules/crawler/lib/sync.ts b/app/modules/crawler/lib/sync.ts index 23861ffc3..fea202698 100644 --- a/app/modules/crawler/lib/sync.ts +++ b/app/modules/crawler/lib/sync.ts @@ -35,7 +35,6 @@ const _ = require('underscore'); const moment = require('moment'); const multimeter = require('multimeter'); const makeQuerablePromise = require('querablep'); -const directory = require('../../../lib/system/directory') const CONST_BLOCKS_CHUNK = 250; const EVAL_REMAINING_INTERVAL = 1000; @@ -624,7 +623,6 @@ class P2PDownloader { private downloads:any = {}; private startResolver:any private downloadStarter:Promise<any> - private getDAL: Promise<FileDAL> constructor( private currency:string, @@ -638,11 +636,6 @@ class P2PDownloader { private dal:FileDAL, private slowOption:any) { - this.getDAL = (async () => { - const params = await directory.getHomeParams(false, '/home/cgeek/.config/duniter/duniter_default') - return new FileDAL(params) - })() - this.TOO_LONG_TIME_DOWNLOAD = "No answer after " + this.MAX_DELAY_PER_DOWNLOAD + "ms, will retry download later."; this.nbBlocksToDownload = Math.max(0, to - localNumber); this.numberOfChunksToDownload = Math.ceil(this.nbBlocksToDownload / CONST_BLOCKS_CHUNK); @@ -886,7 +879,6 @@ class P2PDownloader { */ private async downloadChunk(index:number): Promise<BlockDTO[]> { // The algorithm to download a chunk - const tmpDAL = await this.getDAL const from = this.localNumber + 1 + index * CONST_BLOCKS_CHUNK; let count = CONST_BLOCKS_CHUNK; if (index == this.numberOfChunksToDownload - 1) { @@ -894,19 +886,19 @@ class P2PDownloader { } try { const fileName = this.currency + "/chunk_" + index + "-" + CONST_BLOCKS_CHUNK + ".json"; - if (this.localNumber <= 0 && (await tmpDAL.confDAL.coreFS.exists(fileName))) { + if (this.localNumber <= 0 && (await this.dal.confDAL.coreFS.exists(fileName))) { this.handler[index] = { host: 'filesystem', port: 'blockchain', - resetFunction: () => tmpDAL.confDAL.coreFS.remove(fileName) + resetFunction: () => this.dal.confDAL.coreFS.remove(fileName) }; - return (await tmpDAL.confDAL.coreFS.readJSON(fileName)).blocks; + return (await this.dal.confDAL.coreFS.readJSON(fileName)).blocks; } else { const chunk:any = await this.p2pDownload(from, count, index); // Store the file to avoid re-downloading if (this.localNumber <= 0 && chunk.length === CONST_BLOCKS_CHUNK) { - await tmpDAL.confDAL.coreFS.makeTree(this.currency); - await tmpDAL.confDAL.coreFS.writeJSON(fileName, { blocks: chunk }); + await this.dal.confDAL.coreFS.makeTree(this.currency); + await this.dal.confDAL.coreFS.writeJSON(fileName, { blocks: chunk }); } return chunk; } -- GitLab