diff --git a/app/lib/common-libs/programOptions.ts b/app/lib/common-libs/programOptions.ts index 0274130de70689cb1f9888631064246f184bc3c0..4d85ae5b253d18cf1e85ee7b162e923fd8501028 100644 --- a/app/lib/common-libs/programOptions.ts +++ b/app/lib/common-libs/programOptions.ts @@ -17,6 +17,8 @@ export interface ProgramOptions { mdb?: string home?: string notrim?: boolean + nosbx?: boolean + nopeers?: boolean syncTrace?: string } @@ -24,5 +26,7 @@ export const cliprogram: ProgramOptions = { mdb: opts.mdb, home: opts.home, notrim: opts.notrim, + nosbx: opts.nosbx, + nopeers: opts.nopeers, syncTrace: opts['sync-trace'], } diff --git a/app/modules/crawler/index.ts b/app/modules/crawler/index.ts index eb34d602a45d748084f63969302b2f67cccd919d..e5f5098c5cf7d7d104ca8b2932a7ac7d1be6e803 100644 --- a/app/modules/crawler/index.ts +++ b/app/modules/crawler/index.ts @@ -65,6 +65,7 @@ export const CrawlerDependency = { { value: '--nocautious', desc: 'Do not check blocks validity during sync.'}, { value: '--cautious', desc: 'Check blocks validity during sync (overrides --nocautious option).'}, { value: '--nopeers', desc: 'Do not retrieve peers during sync.'}, + { value: '--nosbx', desc: 'Do not retrieve sandboxes during sync.'}, { value: '--onlypeers', desc: 'Will only try to sync peers.'}, { value: '--slow', desc: 'Download slowly the blokchcain (for low connnections).'}, { value: '--readfilesystem',desc: 'Also read the filesystem to speed up block downloading.'}, @@ -98,7 +99,6 @@ export const CrawlerDependency = { const chunkLength = 0; const interactive = !program.nointeractive; const askedCautious = cautious; - const nopeers = program.nopeers; const noShufflePeers = program.noshuffle; let otherDAL = undefined @@ -112,9 +112,9 @@ export const CrawlerDependency = { const remote = new Synchroniser(server, onHost, onPort, interactive === true, program.slow === true, otherDAL); if (program.onlypeers === true) { - return remote.syncPeers(nopeers, true, onHost, onPort) + return remote.syncPeers(true, onHost, onPort) } else { - return remote.sync(upTo, chunkLength, askedCautious, nopeers, noShufflePeers === true) + return remote.sync(upTo, chunkLength, askedCautious, noShufflePeers === true) } } }, { diff --git a/app/modules/crawler/lib/sync.ts b/app/modules/crawler/lib/sync.ts index 388b973ca8ddba370a952c12c80bd8a4791e9a45..ffc453149b864c68ba9efd0f1fde546b0c4c709f 100644 --- a/app/modules/crawler/lib/sync.ts +++ b/app/modules/crawler/lib/sync.ts @@ -34,6 +34,7 @@ import {CommonConstants} from "../../../lib/common-libs/constants" import {Underscore} from "../../../lib/common-libs/underscore" import {HttpMerkleOfPeers} from "../../bma/lib/dtos" import {DBPeer, JSONDBPeer} from "../../../lib/db/DBPeer" +import {cliprogram} from "../../../lib/common-libs/programOptions" const multimeter = require('multimeter'); const makeQuerablePromise = require('querablep'); @@ -131,7 +132,7 @@ export class Synchroniser extends stream.Duplex { return node.getCurrent(); } - async sync(to:number, chunkLen:number, askedCautious = false, nopeers = false, noShufflePeers = false) { + async sync(to:number, chunkLen:number, askedCautious = false, noShufflePeers = false) { try { @@ -164,7 +165,7 @@ export class Synchroniser extends stream.Duplex { // Peers (just for P2P download) //======= let peers:(JSONDBPeer|null)[] = []; - if (!nopeers && (to - localNumber > 1000)) { // P2P download if more than 1000 blocs + if (!cliprogram.nopeers && (to - localNumber > 1000)) { // P2P download if more than 1000 blocs this.watcher.writeStatus('Peers...'); const merkle = await this.dal.merkleForPeers(); const getPeers:(params:any) => Promise<HttpMerkleOfPeers> = node.getPeers.bind(node); @@ -320,16 +321,20 @@ export class Synchroniser extends stream.Duplex { await this.BlockchainService.saveParametersForRootBlock(BlockDTO.fromJSONObject(rootBlock)) this.server.dal.blockDAL.cleanCache(); - //======= - // Sandboxes - //======= - this.watcher.writeStatus('Synchronizing the sandboxes...'); - await pullSandboxToLocalServer(this.conf.currency, node, this.server, this.server.logger, this.watcher, 1, false) + if (!cliprogram.nosbx) { + //======= + // Sandboxes + //======= + this.watcher.writeStatus('Synchronizing the sandboxes...'); + await pullSandboxToLocalServer(this.conf.currency, node, this.server, this.server.logger, this.watcher, 1, false) + } - //======= - // Peers - //======= - await this.syncPeers(nopeers, fullSync, this.host, this.port, to) + if (!cliprogram.nopeers) { + //======= + // Peers + //======= + await this.syncPeers(fullSync, this.host, this.port, to) + } // Trim the loki data await this.server.dal.loki.flushAndTrimData() @@ -345,8 +350,8 @@ export class Synchroniser extends stream.Duplex { } } - async syncPeers(nopeers:boolean, fullSync:boolean, host:string, port:number, to?:number) { - if (!nopeers && fullSync) { + async syncPeers(fullSync:boolean, host:string, port:number, to?:number) { + if (!cliprogram.nopeers && fullSync) { const peering = await Contacter.fetchPeer(host, port, this.contacterOptions);