Optimize query/queryMulti retrievals (#2371)

* Optimize query/queryMulti retrievals

* Current retrieval on a batch basis

* Dedup staking.account/accounts internally
This commit is contained in:
Jaco Greeff
2020-06-21 13:13:38 +02:00
committed by GitHub
parent 032a0a595c
commit d46d32d9bc
3 changed files with 83 additions and 68 deletions
@@ -18,9 +18,7 @@ export function nextElected (api: ApiInterfaceRx): () => Observable<AccountId[]>
// only populate for next era in the last session, so track both here - entries are not
// subscriptions, so we need a trigger - currentIndex acts as that trigger to refresh
switchMap(({ currentEra }) => api.query.staking.erasStakers.keys(currentEra)),
map((keys): AccountId[] =>
keys.map((key): AccountId => key.args[1] as AccountId)
)
map((keys) => keys.map((key): AccountId => key.args[1] as AccountId))
)
: api.query.staking.currentElected<AccountId[]>()
);