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

feat(1434): add a way to force interval of `pull` command

parent adf740c2
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
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