mirror of
https://github.com/EvernodeXRPL/sashimono.git
synced 2026-04-29 15:38:00 +00:00
A flag added to check if a haertbeat is ongoing (#154)
This commit is contained in:
committed by
GitHub
parent
964cd6a206
commit
d21cf1fdd3
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user