From 45591140af63d6484deb43d0e2f4d9f3d06865e6 Mon Sep 17 00:00:00 2001 From: Milen Radkov Date: Tue, 3 Sep 2024 15:58:23 +0300 Subject: [PATCH] feat(namada): validator AsyncGenerator to start from Consensus subset first --- packages/namada/NamadaPoS.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/namada/NamadaPoS.ts b/packages/namada/NamadaPoS.ts index ed6ba8ce27..789cec3c1b 100644 --- a/packages/namada/NamadaPoS.ts +++ b/packages/namada/NamadaPoS.ts @@ -189,7 +189,21 @@ export async function * fetchValidatorsIter ( connection: NamadaConnection, options?: { parallel?: boolean } ) { - const namadaAddresses = await fetchValidatorAddresses(connection) + + const namadaValidatorsListConsensus = await fetchValidatorsConsensus(connection); + const namadaValidatorsAddresses = await fetchValidatorAddresses(connection) + + const validatorsSet = new Set(); + + for (const validator of namadaValidatorsListConsensus) { + validatorsSet.add(validator.address); + } + + for (const address of namadaValidatorsAddresses) { + validatorsSet.add(address); + } + + const namadaAddresses = Array.from(validatorsSet); const tendermintMetadata = (await Staking.getValidators(connection)).reduce((vs, v)=> Object.assign(vs, {[v.publicKey]: v}), {}) as Record