diff --git a/app/modules/crawler/lib/sync/RemoteSynchronizer.ts b/app/modules/crawler/lib/sync/RemoteSynchronizer.ts index 0dff93c71b2f92fe9c1a3eaf3aafc3e8b8d4c3eb..a39350128b0e9c44e3645cfd88704639bc2d1c88 100644 --- a/app/modules/crawler/lib/sync/RemoteSynchronizer.ts +++ b/app/modules/crawler/lib/sync/RemoteSynchronizer.ts @@ -155,21 +155,17 @@ export class RemoteSynchronizer extends AbstractSynchronizer { // If we know this is a WS2P connection, don't try BMA if (access.isWS2P !== true) { try { + endpoint = + [port == 443 ? "BMAS" : "BASIC_MERKLED_API", host, port].join(" ") + + (path ? (" " + path) : ""); const contacter = await connect( PeerDTO.fromJSONObject({ - endpoints: [ - [port == 443 ? "BMAS" : "BASIC_MERKLED_API", host, port].join( - " " - ) + (path ? " " + path : ""), - ], + endpoints: [endpoint], }), 3000 ); peering = await contacter.getPeer(); api = new BMARemoteContacter(contacter); - endpoint = - [port == 443 ? "BMAS" : "BASIC_MERKLED_API", host, port].join(" ") + - (path ? " " + path : ""); } catch (e) {} } diff --git a/app/modules/crawler/lib/sync/p2p/p2p-candidate.ts b/app/modules/crawler/lib/sync/p2p/p2p-candidate.ts index 56fca9b04b8781f9f514e5856ba6aae67eb05351..65366d71e2230803e8302085fb1e951b8c8fc90a 100644 --- a/app/modules/crawler/lib/sync/p2p/p2p-candidate.ts +++ b/app/modules/crawler/lib/sync/p2p/p2p-candidate.ts @@ -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; })() );