Only memomize via instanceId (#2572)

* Add memoizee instanceId

* Gotcha.

* linitng
This commit is contained in:
Jaco Greeff
2020-09-02 17:13:38 +02:00
committed by GitHub
parent e13514cd94
commit b6d1be6ee5
83 changed files with 244 additions and 246 deletions
@@ -11,8 +11,8 @@ import { map, switchMap } from 'rxjs/operators';
import { memo } from '../util';
export function nextElected (api: ApiInterfaceRx): () => Observable<AccountId[]> {
return memo((): Observable<AccountId[]> =>
export function nextElected (instanceId: string, api: ApiInterfaceRx): () => Observable<AccountId[]> {
return memo(instanceId, (): Observable<AccountId[]> =>
api.query.staking.erasStakers
? api.derive.session.indexes().pipe(
// only populate for next era in the last session, so track both here - entries are not
@@ -27,8 +27,8 @@ export function nextElected (api: ApiInterfaceRx): () => Observable<AccountId[]>
/**
* @description Retrieve latest list of validators
*/
export function validators (api: ApiInterfaceRx): () => Observable<DeriveStakingValidators> {
return memo((): Observable<DeriveStakingValidators> =>
export function validators (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveStakingValidators> {
return memo(instanceId, (): Observable<DeriveStakingValidators> =>
// Sadly the node-template is (for some obscure reason) not comprehensive, so while the derive works
// in all actual real-world deployed chains, it does create some confusion for limited template chains
// NOTE: Not doing multi queries here, since we have validators as a single in the derived newHead