caliper icon indicating copy to clipboard operation
caliper copied to clipboard

TxObserverInterface has implementation code which isn't common across implementers

Open davidkel opened this issue 3 years ago • 0 comments

Observers exist to Observe the caliper system and looks as though the intention is that you can have multiple Observers registered. Looking at the TxObserverInterface I note the following

    /**
     * Called when TXs are submitted.
     * @param {number} count The number of submitted TXs. Can be greater than one for a batch of TXs.
     */
    txSubmitted(count) {
        this.roundStatistics[this.currentRound].txSubmitted(count);
    }

    /**
     * Called when TXs are finished.
     * @param {TxStatus | TxStatus[]} results The result information of the finished TXs. Can be a collection of results for a batch of TXs.
     */
    txFinished(results) {
        this.roundStatistics[this.currentRound].txFinished(results);
    }

these are reused by the InternalTxObserver and are critical to ensure rounds complete correctly and record accurate results however no other observer should use these otherwise it will corrupt the results and could also cause rounds to hang. Luckily all the other observers override these methods.

TxObserverInterface needs to move these method implementations InternalTxObserver. Also all references to round statistics should be moved to InternalTxObserver in the other methods. Ensuring that TxObserverInterface is actually more of an interface (although it will have some basic implementation)

As InternalTxObserver is a critical observer for round statistics perhaps it should be renamed to reflect this.

davidkel avatar May 17 '22 08:05 davidkel