From 004b8c658c354ad1950aa6eef0f2069e9754611e Mon Sep 17 00:00:00 2001 From: Sameer Kumar Subudhi Date: Fri, 10 Nov 2023 10:36:16 +0100 Subject: [PATCH] :bug: Fix apiClient alive check --- services/blockchain-connector/config.js | 6 ++++-- .../blockchain-connector/shared/sdk/events.js | 16 +++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/services/blockchain-connector/config.js b/services/blockchain-connector/config.js index 2781a7f301..40288b1a14 100644 --- a/services/blockchain-connector/config.js +++ b/services/blockchain-connector/config.js @@ -112,8 +112,10 @@ config.job = { }, }; -// Every n number of blocks, verify if client connection is alive -config.connectionVerifyBlockInterval = process.env.CONN_VERIFY_BLOCK_INTERVAL || 10; +// Every n milliseconds, verify if client connection is alive +config.clientConnVerifyInterval = Number( + process.env.CLIENT_CONNECTION_VERIFY_INTERVAL || 30 * 1000, +); // in millisecs config.apiClient = { instantiation: { diff --git a/services/blockchain-connector/shared/sdk/events.js b/services/blockchain-connector/shared/sdk/events.js index fee50055fc..f497ff98fa 100644 --- a/services/blockchain-connector/shared/sdk/events.js +++ b/services/blockchain-connector/shared/sdk/events.js @@ -77,15 +77,13 @@ const getEventsByHeightFormatted = async height => { }; // To ensure API Client is alive and receiving chain events -getNodeInfo().then(nodeInfo => { - setInterval(() => { - if (eventsCounter === 0) { - Signals.get('resetApiClient').dispatch(); - } else if (eventsCounter > 0) { - eventsCounter = 0; - } - }, config.connectionVerifyBlockInterval * nodeInfo.genesis.blockTime * 1000); -}); +setInterval(() => { + if (eventsCounter === 0) { + Signals.get('resetApiClient').dispatch(); + } else if (eventsCounter > 0) { + eventsCounter = 0; + } +}, config.clientConnVerifyInterval); module.exports = { events,