Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
🐛 Fix apiClient alive check
Browse files Browse the repository at this point in the history
  • Loading branch information
sameersubudhi committed Nov 10, 2023
1 parent c2d0fdf commit 004b8c6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 4 additions & 2 deletions services/blockchain-connector/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
16 changes: 7 additions & 9 deletions services/blockchain-connector/shared/sdk/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 004b8c6

Please sign in to comment.