From 40dcf58f97ea5f9c4bf4a0e4830a0f2da3ea587b Mon Sep 17 00:00:00 2001 From: onmax Date: Wed, 20 Nov 2024 05:02:59 -0600 Subject: [PATCH 1/4] feat: improve validator fetch logic --- src/network.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/network.ts b/src/network.ts index a5f2f9b5e..5e37081a3 100644 --- a/src/network.ts +++ b/src/network.ts @@ -217,7 +217,12 @@ export async function launchNetwork() { network$.peerCount = peerCount; }); + let lastValidatorRequest = { epoch: Infinity, ts: 0 }; async function updateValidators() { + const now = Date.now(); + if (currentEpoch === lastValidatorRequest.epoch || now - lastValidatorRequest.ts < 60000) return; + lastValidatorRequest = { epoch: currentEpoch, ts: now }; + await client.waitForConsensusEstablished(); const contract = (await retry( () => client.getAccount(STAKING_CONTRACT_ADDRESS) as Promise, @@ -251,8 +256,9 @@ export async function launchNetwork() { }; const { config } = useConfig(); - const apiValidators = await fetch(config.staking.validatorsEndpoint) - .then((res) => res.json()).catch(() => []) as ApiValidator[]; + const apiValidators = await retry( + () => fetch(config.staking.validatorsEndpoint).then((res) => res.json()).catch(() => []), 1000, 3, + ); // TODO: Make it work even in the case this request fails const validatorData: Record = {}; for (const apiValidator of apiValidators) { From 78ccb1a325ab4cfbc57979fc313febba3e4605a6 Mon Sep 17 00:00:00 2001 From: onmax Date: Wed, 20 Nov 2024 08:31:04 -0600 Subject: [PATCH 2/4] feat: update validator logo handling and API endpoint configuration --- src/components/staking/ValidatorIcon.vue | 11 ++++++++++- src/config/config.local.ts | 2 +- src/config/config.mainnet.ts | 2 +- src/config/config.testnet.ts | 2 +- src/network.ts | 6 ++++-- src/stores/Staking.ts | 5 +++-- 6 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/components/staking/ValidatorIcon.vue b/src/components/staking/ValidatorIcon.vue index 0662a0bdc..2650754f5 100644 --- a/src/components/staking/ValidatorIcon.vue +++ b/src/components/staking/ValidatorIcon.vue @@ -1,11 +1,12 @@