Skip to content
Snippets Groups Projects
Commit 4220efcc authored by Éloïs's avatar Éloïs
Browse files

Merge branch 'pini' into dev

parents f21790a7 7a59f46f
No related branches found
No related tags found
No related merge requests found
......@@ -90,21 +90,30 @@ export class P2pCandidate {
this.dlPromise = querablep(
(async () => {
// We try to download the blocks
let blocks: BlockDTO[] | null;
try {
blocks = await (this.api as IRemoteContacter).getBlocks(count, from);
} catch (e) {
// Unfortunately this can fail
blocks = null;
error = e;
let blocks: BlockDTO[] = [];
let tries = 5;
while (tries > 0) {
try {
blocks = await (this.api as IRemoteContacter).getBlocks(
count,
from
);
} catch (e) {
// Unfortunately this can fail
blocks = [];
this.logger.error(e);
}
if (blocks.length != count) {
this.logger.error("Wrong number of blocks from %s", this.hostName);
tries--;
} else {
break;
}
}
this.responseTimes.push(Date.now() - start);
// Only keep a flow of 5 ttas for the node
if (this.responseTimes.length > 5) this.responseTimes.shift();
this.nbSuccess++;
if (error) {
throw error;
}
return blocks;
})()
);
......
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