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

[fix] very initial sync (after a `reset all` for example) was not taking...

[fix] very initial sync (after a `reset all` for example) was not taking currency parameters correctly
parent 0ada51ce
No related branches found
No related tags found
No related merge requests found
...@@ -125,6 +125,13 @@ export class Synchroniser extends stream.Duplex { ...@@ -125,6 +125,13 @@ export class Synchroniser extends stream.Duplex {
} }
to = rCurrent.number || 0 to = rCurrent.number || 0
const rootBlock = await this.syncStrategy.getBlock(0)
if (!rootBlock) {
throw 'Could not get root block. Sync aborted.'
}
await this.BlockchainService.saveParametersForRootBlock(rootBlock)
await this.server.reloadConf()
await this.syncStrategy.initWithKnownLocalAndToAndCurrency(to, localNumber, rCurrent.currency) await this.syncStrategy.initWithKnownLocalAndToAndCurrency(to, localNumber, rCurrent.currency)
//============ //============
...@@ -256,9 +263,6 @@ export class Synchroniser extends stream.Duplex { ...@@ -256,9 +263,6 @@ export class Synchroniser extends stream.Duplex {
clearInterval(logInterval); clearInterval(logInterval);
} }
// Save currency parameters given by root block
const rootBlock = await this.server.dal.getFullBlockOf(0)
await this.BlockchainService.saveParametersForRootBlock(BlockDTO.fromJSONObject(rootBlock))
this.server.dal.blockDAL.cleanCache(); this.server.dal.blockDAL.cleanCache();
if (!cliprogram.nosbx) { if (!cliprogram.nosbx) {
......
...@@ -39,6 +39,7 @@ import {ProxiesConf} from './app/lib/proxy'; ...@@ -39,6 +39,7 @@ import {ProxiesConf} from './app/lib/proxy';
import {Directory, FileSystem} from "./app/lib/system/directory" import {Directory, FileSystem} from "./app/lib/system/directory"
import {DataErrors} from "./app/lib/common-libs/errors" import {DataErrors} from "./app/lib/common-libs/errors"
import {DBPeer} from "./app/lib/db/DBPeer" import {DBPeer} from "./app/lib/db/DBPeer"
import {Underscore} from "./app/lib/common-libs/underscore"
export interface HookableServer { export interface HookableServer {
generatorGetJoinData: (...args:any[]) => Promise<any> generatorGetJoinData: (...args:any[]) => Promise<any>
...@@ -158,9 +159,18 @@ export class Server extends stream.Duplex implements HookableServer { ...@@ -158,9 +159,18 @@ export class Server extends stream.Duplex implements HookableServer {
await this.dal.close() await this.dal.close()
} }
async loadConf(useDefaultConf:any = false) { async reloadConf() {
await this.loadConf(false, true)
}
async loadConf(useDefaultConf:any = false, reuseExisting = false) {
logger.debug('Loading conf...'); logger.debug('Loading conf...');
this.conf = await this.dal.loadConf(this.overrideConf, useDefaultConf) const loaded = await this.dal.loadConf(this.overrideConf, useDefaultConf)
if (!reuseExisting || !this.conf) {
this.conf = loaded
} else {
Underscore.extend(this.conf, loaded) // Overwrite the current conf
}
// Default values // Default values
this.conf.proxiesConf = this.conf.proxiesConf === undefined ? new ProxiesConf() : this.conf.proxiesConf this.conf.proxiesConf = this.conf.proxiesConf === undefined ? new ProxiesConf() : this.conf.proxiesConf
this.conf.remoteipv6 = this.conf.remoteipv6 === undefined ? this.conf.ipv6 : this.conf.remoteipv6 this.conf.remoteipv6 = this.conf.remoteipv6 === undefined ? this.conf.ipv6 : this.conf.remoteipv6
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment