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

[fix] Be able to switch from Ğ1 to Ğ1-Test network

parent 54308e31
No related branches found
No related tags found
No related merge requests found
...@@ -188,7 +188,7 @@ export class Synchroniser extends stream.Duplex { ...@@ -188,7 +188,7 @@ export class Synchroniser extends stream.Duplex {
// We use cautious mode if it is asked, or not particulary asked but blockchain has been started // We use cautious mode if it is asked, or not particulary asked but blockchain has been started
const cautious = (askedCautious === true || localNumber >= 0); const cautious = (askedCautious === true || localNumber >= 0);
const shuffledPeers = noShufflePeers ? peers : _.shuffle(peers); const shuffledPeers = noShufflePeers ? peers : _.shuffle(peers);
const downloader = new P2PDownloader(localNumber, to, rCurrent.hash, shuffledPeers, this.watcher, this.logger, hashf, this.dal, this.slowOption); const downloader = new P2PDownloader(rCurrent.currency, localNumber, to, rCurrent.hash, shuffledPeers, this.watcher, this.logger, hashf, this.dal, this.slowOption);
downloader.start(); downloader.start();
...@@ -611,6 +611,7 @@ class P2PDownloader { ...@@ -611,6 +611,7 @@ class P2PDownloader {
private downloadStarter:Promise<any> private downloadStarter:Promise<any>
constructor( constructor(
private currency:string,
private localNumber:number, private localNumber:number,
private to:number, private to:number,
private toHash:string, private toHash:string,
...@@ -870,7 +871,7 @@ class P2PDownloader { ...@@ -870,7 +871,7 @@ class P2PDownloader {
count = this.nbBlocksToDownload % CONST_BLOCKS_CHUNK || CONST_BLOCKS_CHUNK; count = this.nbBlocksToDownload % CONST_BLOCKS_CHUNK || CONST_BLOCKS_CHUNK;
} }
try { try {
const fileName = "blockchain/chunk_" + index + "-" + CONST_BLOCKS_CHUNK + ".json"; const fileName = this.currency + "/chunk_" + index + "-" + CONST_BLOCKS_CHUNK + ".json";
if (this.localNumber <= 0 && (await this.dal.confDAL.coreFS.exists(fileName))) { if (this.localNumber <= 0 && (await this.dal.confDAL.coreFS.exists(fileName))) {
this.handler[index] = { this.handler[index] = {
host: 'filesystem', host: 'filesystem',
...@@ -882,7 +883,7 @@ class P2PDownloader { ...@@ -882,7 +883,7 @@ class P2PDownloader {
const chunk:any = await this.p2pDownload(from, count, index); const chunk:any = await this.p2pDownload(from, count, index);
// Store the file to avoid re-downloading // Store the file to avoid re-downloading
if (this.localNumber <= 0 && chunk.length === CONST_BLOCKS_CHUNK) { if (this.localNumber <= 0 && chunk.length === CONST_BLOCKS_CHUNK) {
await this.dal.confDAL.coreFS.makeTree('blockchain'); await this.dal.confDAL.coreFS.makeTree(this.currency);
await this.dal.confDAL.coreFS.writeJSON(fileName, { blocks: chunk }); await this.dal.confDAL.coreFS.writeJSON(fileName, { blocks: chunk });
} }
return chunk; return chunk;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment