From c1ba37384deb10b315b460e0d56d39888e83353a Mon Sep 17 00:00:00 2001 From: Udith Indrakantha <45740208+Udith-Gayan@users.noreply.github.com> Date: Tue, 5 Jul 2022 16:04:22 +0530 Subject: [PATCH 1/3] Lasthearbeatledger gets updated after successful heartbeat (#152) --- mb-xrpl/lib/message-board.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mb-xrpl/lib/message-board.js b/mb-xrpl/lib/message-board.js index 13e11a5..c65cfb0 100644 --- a/mb-xrpl/lib/message-board.js +++ b/mb-xrpl/lib/message-board.js @@ -81,12 +81,12 @@ class MessageBoard { // Sending heartbeat every CONF_HOST_HEARTBEAT_FREQ moments. if (this.lastHeartbeatMoment === 0 || (currentMoment % this.hostClient.config.hostHeartbeatFreq === 0 && currentMoment !== this.lastHeartbeatMoment)) { - this.lastHeartbeatMoment = currentMoment; console.log(`Reporting heartbeat at Moment ${this.lastHeartbeatMoment}...`) try { await this.hostClient.heartbeat(); + this.lastHeartbeatMoment = currentMoment; } catch (err) { if (err.code === 'tecHOOK_REJECTED') From 964cd6a2068131cab8dd82c6f350b5f8bf8b8838 Mon Sep 17 00:00:00 2001 From: Udith Indrakantha <45740208+Udith-Gayan@users.noreply.github.com> Date: Thu, 7 Jul 2022 09:50:59 +0530 Subject: [PATCH 2/3] Replacing killall with pkill (#153) --- installer/sashimono-uninstall.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/installer/sashimono-uninstall.sh b/installer/sashimono-uninstall.sh index 3606fcb..69d8c94 100755 --- a/installer/sashimono-uninstall.sh +++ b/installer/sashimono-uninstall.sh @@ -155,7 +155,10 @@ if grep -q "^$MB_XRPL_USER:" /etc/passwd; then fi echo "Deleting message board user..." - killall -u $MB_XRPL_USER # Kill any running processes. + # Killall command is not found in every linux systems, therefore pkill command is used. + # A small timeout(0.1 second) is applied before deleting the user because it takes some time to kill all the processes + pkill -u $MB_XRPL_USER # Kill any running processes. + sleep 0.1 userdel -f "$MB_XRPL_USER" rm -r /home/"${MB_XRPL_USER:?}" From d21cf1fdd38e5b004a0fa17b3a4f224f6bd4d31e Mon Sep 17 00:00:00 2001 From: Udith Indrakantha <45740208+Udith-Gayan@users.noreply.github.com> Date: Thu, 7 Jul 2022 12:16:25 +0530 Subject: [PATCH 3/3] A flag added to check if a haertbeat is ongoing (#154) --- mb-xrpl/lib/message-board.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mb-xrpl/lib/message-board.js b/mb-xrpl/lib/message-board.js index c65cfb0..17530c9 100644 --- a/mb-xrpl/lib/message-board.js +++ b/mb-xrpl/lib/message-board.js @@ -73,6 +73,7 @@ class MessageBoard { await this.hostClient.updateRegInfo(this.activeInstanceCount, this.cfg.version); this.db.close(); + let ongoingHeartbeat = false; // Check for instance expiry. this.xrplApi.on(evernode.XrplApiEvents.LEDGER, async (e) => { this.lastValidatedLedgerIndex = e.ledger_index; @@ -80,9 +81,10 @@ class MessageBoard { const currentMoment = await this.hostClient.getMoment(e.ledger_index); // Sending heartbeat every CONF_HOST_HEARTBEAT_FREQ moments. - if (this.lastHeartbeatMoment === 0 || (currentMoment % this.hostClient.config.hostHeartbeatFreq === 0 && currentMoment !== this.lastHeartbeatMoment)) { - - console.log(`Reporting heartbeat at Moment ${this.lastHeartbeatMoment}...`) + if ( ! ongoingHeartbeat && + (this.lastHeartbeatMoment === 0 || (currentMoment % this.hostClient.config.hostHeartbeatFreq === 0 && currentMoment !== this.lastHeartbeatMoment))) { + ongoingHeartbeat = true; + console.log(`Reporting heartbeat at Moment ${this.lastHeartbeatMoment}...`); try { await this.hostClient.heartbeat(); @@ -94,6 +96,9 @@ class MessageBoard { else console.log("Heartbeat tx error", err); } + finally { + ongoingHeartbeat = false; + } } // Filter out instances which needed to be expired and destroy them.