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 37 38 39 40 | 43x 43x 43x 132x 132x 119x 119x 2x 2x 43x 132x 132x 132x 132x 132x 1x 132x 236x | import { AssetProvider } from '@cardano-sdk/core'; import { BehaviorSubject } from 'rxjs'; import { CLEAN_FN_STATS, ProviderFnStats, ProviderTracker } from './ProviderTracker'; export class AssetProviderStats { readonly healthCheck$ = new BehaviorSubject<ProviderFnStats>(CLEAN_FN_STATS); readonly getAsset$ = new BehaviorSubject<ProviderFnStats>(CLEAN_FN_STATS); shutdown() { this.healthCheck$.complete(); this.getAsset$.complete(); } reset() { this.healthCheck$.next(CLEAN_FN_STATS); this.getAsset$.next(CLEAN_FN_STATS); } } /** Wraps a AssetProvider, tracking # of calls of each function */ export class TrackedAssetProvider extends ProviderTracker implements AssetProvider { readonly stats = new AssetProviderStats(); readonly healthCheck: AssetProvider['healthCheck']; readonly getAsset: AssetProvider['getAsset']; readonly getAssets: AssetProvider['getAssets']; constructor(assetProvider: AssetProvider) { super(); assetProvider = assetProvider; this.healthCheck = () => this.trackedCall(() => assetProvider.healthCheck(), this.stats.healthCheck$); this.getAsset = ({ assetId, extraData }) => this.trackedCall(() => assetProvider.getAsset({ assetId, extraData }), this.stats.getAsset$); this.getAssets = ({ assetIds, extraData }) => this.trackedCall(() => assetProvider.getAssets({ assetIds, extraData }), this.stats.getAsset$); } } |