diff --git a/app/lib/dal/indexDAL/loki/LokiCollection.ts b/app/lib/dal/indexDAL/loki/LokiCollection.ts index 515ff9c8c43127d56f1ef98c22f9f167bb9d3950..c912a75476c95a589caa7b97523915c955702e14 100644 --- a/app/lib/dal/indexDAL/loki/LokiCollection.ts +++ b/app/lib/dal/indexDAL/loki/LokiCollection.ts @@ -36,7 +36,8 @@ export class LokiProxyCollection<T> implements LokiCollection<T> { return this.collection.chain() } - setDisableChangesAPI(disable: boolean) { - this.collection.setDisableChangesAPI(disable) + setChangesApi(enabled: boolean) { + this.collection.setChangesApi(enabled) + ;(this.collection as any).disableDeltaChangesApi = true } } diff --git a/app/lib/dal/indexDAL/loki/LokiCollectionManager.ts b/app/lib/dal/indexDAL/loki/LokiCollectionManager.ts index 38c696f68dd792dccb49a28876174c6e3caa5d6a..fe0484af9afa9429a0a421622438fdd7edf894e9 100755 --- a/app/lib/dal/indexDAL/loki/LokiCollectionManager.ts +++ b/app/lib/dal/indexDAL/loki/LokiCollectionManager.ts @@ -29,11 +29,11 @@ export abstract class LokiCollectionManager<T> implements LokiDAO { } public enableChangesAPI() { - this.collection.setDisableChangesAPI(false) + this.collection.setChangesApi(true) } public disableChangesAPI() { - this.collection.setDisableChangesAPI(true) + this.collection.setChangesApi(false) } async init(): Promise<void> { diff --git a/app/lib/dal/indexDAL/loki/LokiTypes.ts b/app/lib/dal/indexDAL/loki/LokiTypes.ts index 4e4f87d1596674911cb68ac34155c9d36ca89902..ff34a77f47e034ccdee83ac46d01a97507545932 100644 --- a/app/lib/dal/indexDAL/loki/LokiTypes.ts +++ b/app/lib/dal/indexDAL/loki/LokiTypes.ts @@ -13,7 +13,7 @@ export interface LokiCollection<T> { chain(): LokiChainableFind<T> - setDisableChangesAPI(disable: boolean): void + setChangesApi(disable: boolean): void } export interface LokiChainableFind<T> { diff --git a/app/modules/crawler/index.ts b/app/modules/crawler/index.ts index a86cfeb99c49b6bb5c89f02d30e51a28d1186a26..2d72d7b411e6751aa1d118c79c3178925db994ed 100644 --- a/app/modules/crawler/index.ts +++ b/app/modules/crawler/index.ts @@ -51,14 +51,14 @@ export const CrawlerDependency = { synchronize: (server:Server, onHost:string, onPort:number, upTo:number, chunkLength:number) => { const strategy = new RemoteSynchronizer(onHost, onPort, server) 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 { flow: remote, - syncPromise: (async () => { - await server.dal.disableChangesAPI() - await syncPromise - await server.dal.enableChangesAPI() - })() + syncPromise }; }, @@ -91,7 +91,7 @@ export const CrawlerDependency = { name: 'sync [source] [to]', desc: 'Synchronize blockchain from a remote Duniter node', 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 to = params[1] const HOST_PATTERN = /^[^:/]+(:[0-9]{1,5})?$/