Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | 42x 42x 42x 42x | import { BehaviorSubject } from 'rxjs';
import { CLEAN_FN_STATS, ProviderFnStats, ProviderTracker } from './ProviderTracker';
import { DRepProvider } from '@cardano-sdk/core';
export class DrepProviderStats {
readonly healthCheck$ = new BehaviorSubject<ProviderFnStats>(CLEAN_FN_STATS);
readonly getDRepInfo$ = new BehaviorSubject<ProviderFnStats>(CLEAN_FN_STATS);
shutdown() {
this.healthCheck$.complete();
this.getDRepInfo$.complete();
}
reset() {
this.healthCheck$.next(CLEAN_FN_STATS);
this.getDRepInfo$.next(CLEAN_FN_STATS);
}
}
/** Wraps a DRepProvider, tracking # of calls of each function */
export class TrackedDrepProvider extends ProviderTracker implements DRepProvider {
readonly stats = new DrepProviderStats();
readonly healthCheck: DRepProvider['healthCheck'];
readonly getDRepInfo: DRepProvider['getDRepInfo'];
readonly getDRepsInfo: DRepProvider['getDRepsInfo'];
constructor(drepProvider: DRepProvider) {
super();
drepProvider = drepProvider;
this.healthCheck = () => this.trackedCall(() => drepProvider.healthCheck(), this.stats.healthCheck$);
this.getDRepInfo = (args) => this.trackedCall(() => drepProvider.getDRepInfo(args), this.stats.getDRepInfo$);
this.getDRepsInfo = (args) => this.trackedCall(() => drepProvider.getDRepsInfo(args), this.stats.getDRepInfo$);
}
}
|