@hyperledger/caliper-core
Advanced tools
Comparing version 0.6.1-unstable-20241117120936 to 0.6.1-unstable-20241120090114
@@ -23,2 +23,6 @@ /* | ||
const logger = CaliperUtils.getLogger('InternalTxObserver'); | ||
const DEFAULT_UPDATE_INTERVAL = 1000; // in milliseconds | ||
/** | ||
@@ -38,2 +42,7 @@ * Internal TX observer used by the worker process to driver TX scheduling and report round statistics | ||
this.updateInterval = ConfigUtil.get(ConfigUtil.keys.Observer.Internal.Interval); | ||
// Check if the updateInterval is not a valid number, and use a default value if needed | ||
if (typeof this.updateInterval !== 'number' || isNaN(this.updateInterval) || this.updateInterval < 0) { | ||
logger.warn(`Invalid update interval (${this.updateInterval}), using default value of ${DEFAULT_UPDATE_INTERVAL}ms`); | ||
this.updateInterval = DEFAULT_UPDATE_INTERVAL; | ||
} | ||
this.intervalObject = undefined; | ||
@@ -67,14 +76,20 @@ this.messengerUUID = messenger.getUUID(); | ||
async deactivate() { | ||
await super.deactivate(); | ||
try { | ||
await super.deactivate(); | ||
if (this.intervalObject) { | ||
clearInterval(this.intervalObject); | ||
if (this.intervalObject) { | ||
clearInterval(this.intervalObject); | ||
await this._sendUpdate(); | ||
await CaliperUtils.sleep(this.updateInterval); | ||
await this._sendUpdate(); | ||
await CaliperUtils.sleep(this.updateInterval); | ||
this.intervalObject = null; // Explicitly set it to null after clearing | ||
// TODO: the txResult message should be enough | ||
// or the round-end message should include the final stats | ||
let txResetMessage = new TxResetMessage(this.messengerUUID, [this.managerUuid]); | ||
await this.messenger.send(txResetMessage); | ||
// TODO: the txResult message should be enough | ||
// or the round-end message should include the final stats | ||
let txResetMessage = new TxResetMessage(this.messengerUUID, [this.managerUuid]); | ||
await this.messenger.send(txResetMessage); | ||
} | ||
}catch (error) { | ||
logger.error(`Error during deactivation: ${error.message}`); | ||
throw error; | ||
} | ||
@@ -81,0 +96,0 @@ } |
@@ -76,3 +76,6 @@ /* | ||
this.active = false; | ||
this.roundStatistics[this.currentRound].deactivate(); | ||
const roundStat = this.roundStatistics[this.currentRound]; | ||
if(roundStat){ | ||
roundStat.deactivate(); | ||
} | ||
} | ||
@@ -85,3 +88,6 @@ | ||
txSubmitted(count) { | ||
this.roundStatistics[this.currentRound].txSubmitted(count); | ||
const roundStat = this.roundStatistics[this.currentRound]; | ||
if(roundStat){ | ||
roundStat.txSubmitted(count); | ||
} | ||
} | ||
@@ -94,3 +100,6 @@ | ||
txFinished(results) { | ||
this.roundStatistics[this.currentRound].txFinished(results); | ||
const roundStat = this.roundStatistics[this.currentRound]; | ||
if(roundStat){ | ||
roundStat.txFinished(results); | ||
} | ||
} | ||
@@ -97,0 +106,0 @@ |
{ | ||
"name": "@hyperledger/caliper-core", | ||
"description": "Core Hyperledger Caliper module, used for running performance benchmarks that interact with blockchain technologies", | ||
"version": "0.6.1-unstable-20241117120936", | ||
"version": "0.6.1-unstable-20241120090114", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
437234
9894