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

[fix] #1135 Regularly try to reconnect to the WS2P network

parent c30fcd64
No related branches found
No related tags found
No related merge requests found
......@@ -77,6 +77,9 @@ export class WS2PCluster {
// The triggerer of a buffer of heads' sending
private headsTimeout:NodeJS.Timer|null = null
// A timer to regularly reconnect to the network in case we are below the minimum connections' count
private reconnectionInteval:NodeJS.Timer|null = null
private constructor(private server:Server) {
this.messageHandler = new WS2PServerMessageHandler(this.server, this)
// Conf: max private connections
......@@ -622,6 +625,8 @@ export class WS2PCluster {
}
async startCrawling(waitConnection = false) {
// For connectivity
this.reconnectionInteval = setInterval(() => this.server.push({ ws2p: 'disconnected' }), 1000 * 60 * 10)
// For blocks
if (this.syncBlockInterval)
clearInterval(this.syncBlockInterval);
......@@ -650,6 +655,9 @@ export class WS2PCluster {
}
async stopCrawling() {
if (this.reconnectionInteval) {
clearInterval(this.reconnectionInteval)
}
if (this.syncBlockInterval) {
clearInterval(this.syncBlockInterval)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment