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

[fix] sync: was long within duniter-ui

parent 5517bdad
No related branches found
No related tags found
No related merge requests found
...@@ -36,7 +36,8 @@ export class LokiProxyCollection<T> implements LokiCollection<T> { ...@@ -36,7 +36,8 @@ export class LokiProxyCollection<T> implements LokiCollection<T> {
return this.collection.chain() return this.collection.chain()
} }
setDisableChangesAPI(disable: boolean) { setChangesApi(enabled: boolean) {
this.collection.setDisableChangesAPI(disable) this.collection.setChangesApi(enabled)
;(this.collection as any).disableDeltaChangesApi = true
} }
} }
...@@ -29,11 +29,11 @@ export abstract class LokiCollectionManager<T> implements LokiDAO { ...@@ -29,11 +29,11 @@ export abstract class LokiCollectionManager<T> implements LokiDAO {
} }
public enableChangesAPI() { public enableChangesAPI() {
this.collection.setDisableChangesAPI(false) this.collection.setChangesApi(true)
} }
public disableChangesAPI() { public disableChangesAPI() {
this.collection.setDisableChangesAPI(true) this.collection.setChangesApi(false)
} }
async init(): Promise<void> { async init(): Promise<void> {
......
...@@ -13,7 +13,7 @@ export interface LokiCollection<T> { ...@@ -13,7 +13,7 @@ export interface LokiCollection<T> {
chain(): LokiChainableFind<T> chain(): LokiChainableFind<T>
setDisableChangesAPI(disable: boolean): void setChangesApi(disable: boolean): void
} }
export interface LokiChainableFind<T> { export interface LokiChainableFind<T> {
......
...@@ -51,14 +51,14 @@ export const CrawlerDependency = { ...@@ -51,14 +51,14 @@ export const CrawlerDependency = {
synchronize: (server:Server, onHost:string, onPort:number, upTo:number, chunkLength:number) => { synchronize: (server:Server, onHost:string, onPort:number, upTo:number, chunkLength:number) => {
const strategy = new RemoteSynchronizer(onHost, onPort, server) const strategy = new RemoteSynchronizer(onHost, onPort, server)
const remote = new Synchroniser(server, strategy) const remote = new Synchroniser(server, strategy)
const syncPromise = remote.sync(upTo, chunkLength) const syncPromise = (async () => {
await server.dal.disableChangesAPI()
await remote.sync(upTo, chunkLength)
await server.dal.enableChangesAPI()
})()
return { return {
flow: remote, flow: remote,
syncPromise: (async () => { syncPromise
await server.dal.disableChangesAPI()
await syncPromise
await server.dal.enableChangesAPI()
})()
}; };
}, },
...@@ -91,7 +91,7 @@ export const CrawlerDependency = { ...@@ -91,7 +91,7 @@ export const CrawlerDependency = {
name: 'sync [source] [to]', name: 'sync [source] [to]',
desc: 'Synchronize blockchain from a remote Duniter node', desc: 'Synchronize blockchain from a remote Duniter node',
preventIfRunning: true, preventIfRunning: true,
onDatabaseExecute: async (server:Server, conf:ConfDTO, program:any, params:any) => { onDatabaseExecute: async (server:Server, conf:ConfDTO, program:any, params:any): Promise<any> => {
const source = params[0] const source = params[0]
const to = params[1] const to = params[1]
const HOST_PATTERN = /^[^:/]+(:[0-9]{1,5})?$/ const HOST_PATTERN = /^[^:/]+(:[0-9]{1,5})?$/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment