Cleanup staking info (#1532)

* Cleanup staking info

* Cache calls

* V1, V2 (Aura & Babe) tested & working

* Hopefully pacify docs build

* Second time lucky?

* Third time lucky?

* Fouth time
This commit is contained in:
Jaco Greeff
2019-10-30 14:15:20 +01:00
committed by GitHub
parent 2676909cd0
commit 8379689eaa
17 changed files with 232 additions and 102 deletions
+2 -1
View File
@@ -58,7 +58,8 @@ function derivePhragmen (candidates: Vec<AccountId>, members: Vec<[AccountId, Ba
}
function queryPhragmen (api: ApiInterfaceRx): Observable<DerivedElectionsInfo> {
// NOTE We have an issue where candidates can return `null` for an empty array
// NOTE We have an issue where candidates can return `null` for an empty array, hence
// we are not using multi queries here, so empty array is empty (instead of space-filled)
return combineLatest([
api.query.electionsPhragmen.candidates<Vec<AccountId>>(),
api.query.electionsPhragmen.members<Vec<[AccountId, Balance] & Codec>>()
+3 -1
View File
@@ -26,8 +26,10 @@ import { voterPositions } from './voterPositions';
* ```
*/
export function voters (api: ApiInterfaceRx): () => Observable<Vec<AccountId>> {
const voterPositionsCall = voterPositions(api);
return (): Observable<Vec<AccountId>> =>
voterPositions(api)().pipe(
voterPositionsCall().pipe(
map(
(voterPositions: DerivedVoterPositions): Vec<AccountId> =>
createType(