Additional derive cleanups (#4307)

* Additional derive cleanups

* Adjust

* Multi cache set

* Adjust mapping
This commit is contained in:
Jaco
2021-12-09 12:12:05 +02:00
committed by GitHub
parent 584cbb994b
commit e32ac213b9
21 changed files with 129 additions and 154 deletions
+2 -11
View File
@@ -12,7 +12,7 @@ import { combineLatest, map, of } from 'rxjs';
import { deriveCache, memo } from '../util';
import { getEraCache } from './cache';
import { erasHistoricApply } from './util';
import { combineEras, erasHistoricApply } from './util';
const CACHE_KEY = 'eraSlashes';
@@ -58,14 +58,5 @@ export function eraSlashes (instanceId: string, api: ApiInterfaceRx): (era: EraI
);
}
export function _erasSlashes (instanceId: string, api: ApiInterfaceRx): (eras: EraIndex[], withActive: boolean) => Observable<DeriveEraSlashes[]> {
return memo(instanceId, (eras: EraIndex[], withActive: boolean): Observable<DeriveEraSlashes[]> =>
eras.length
? combineLatest(
eras.map((era) => api.derive.staking._eraSlashes(era, withActive))
)
: of([])
);
}
export const _erasSlashes = combineEras('_eraSlashes');
export const erasSlashes = erasHistoricApply('_erasSlashes');