From 03463ab23a20420eedf72b3a8012214494218ba1 Mon Sep 17 00:00:00 2001 From: cgeek <cem.moreau@gmail.com> Date: Mon, 22 Aug 2022 11:21:00 +0200 Subject: [PATCH] feat(1434): add a way to force interval of `pull` command --- app/modules/crawler/index.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/modules/crawler/index.ts b/app/modules/crawler/index.ts index bb3d86990..5c4bf9768 100644 --- a/app/modules/crawler/index.ts +++ b/app/modules/crawler/index.ts @@ -484,7 +484,7 @@ export const CrawlerDependency = { }, }, { - name: "pull <from> [<number>]", + name: "pull <from> [<start>] [<end>]", desc: "Pull blocks from <from> source up to block <number>", onDatabaseExecute: async ( server: Server, @@ -493,7 +493,11 @@ export const CrawlerDependency = { params: any ) => { const source: string = params[0]; - const to = parseInt(params[1]); + const to = parseInt(params[2] || params[1]); + let from: null | number = null; + if (params[2]) { + from = parseInt(params[1]); + } if ( !source || !(source.match(HOST_PATTERN) || source.match(FILE_PATTERN)) @@ -510,6 +514,9 @@ export const CrawlerDependency = { try { const fromHost = await connect(peer); let current: DBBlock | null = await server.dal.getCurrentBlockOrNull(); + if (from) { + current = { number: from - 1 } as any; + } // Loop until an error occurs while (current && (isNaN(to) || current.number < to)) { current = await fromHost.getBlock(current.number + 1); -- GitLab