Additional derive cleanups (#4307)
* Additional derive cleanups * Adjust * Multi cache set * Adjust mapping
This commit is contained in:
@@ -25,3 +25,16 @@ export function getEraMultiCache <T> (CACHE_KEY: string, eras: EraIndex[], withA
|
||||
|
||||
return cached;
|
||||
}
|
||||
|
||||
export function setEraMultiCache <T extends { era: EraIndex }> (CACHE_KEY: string, withActive: boolean, values: T[]): T[] {
|
||||
!withActive && values.forEach((v) => deriveCache.set(`${CACHE_KEY}-${v.era.toString()}`, v));
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
export function filterCachedEras <T extends { era: EraIndex }> (eras: EraIndex[], cached: T[], query: T[]): T[] {
|
||||
return eras.map((e) =>
|
||||
cached.find(({ era }) => e.eq(era)) ||
|
||||
query.find(({ era }) => e.eq(era)) as T
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user