From 4afac86b66862b24955d96034514683713d54ac5 Mon Sep 17 00:00:00 2001 From: Nicola Benaglia Date: Sat, 21 Jun 2025 13:29:42 +0200 Subject: [PATCH] Refactor functions --- src/components/Minting/MintingStats.tsx | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/components/Minting/MintingStats.tsx b/src/components/Minting/MintingStats.tsx index 09e0397..733349e 100644 --- a/src/components/Minting/MintingStats.tsx +++ b/src/components/Minting/MintingStats.tsx @@ -183,7 +183,7 @@ export const countReward = ( nodeStatus, tier4Online: number ): number => { - if (accountInfo != null) { + if (accountInfo != null && (addressLevel && addressLevel.length > 0) ) { const level = accountInfo.level; if (level === 0) { return 0; @@ -273,7 +273,7 @@ export const countRewardDay = ( nodeStatus, tier4Online: number ): number => { - if (accountInfo != null) { + if (accountInfo != null && (addressLevel && addressLevel.length > 0) ) { const level = accountInfo.level; const timeCalc = averageBlockDay(adminInfo, nodeHeightBlock); if (level === 0) { @@ -426,11 +426,12 @@ export const levelUpBlocks = (accountInfo, nodeStatus): number => { ) return 0; + const nextBatch = 1000 - (nodeStatus.height % 1000); const countBlocks = accountTargetBlocks(accountInfo?.level)! - - (accountInfo?.blocksMinted + accountInfo?.blocksMintedAdjustment); - - return countBlocks; + (accountInfo?.blocksMinted + accountInfo?.blocksMintedAdjustment) + 1000; + const countBlocksActual = countBlocks + nextBatch - (countBlocks % 1000); + return countBlocksActual; }; export const levelUpDays = ( @@ -446,11 +447,13 @@ export const levelUpDays = ( ) return undefined; + const nextBatch = 1000 - (nodeStatus.height % 1000); const countBlocks = accountTargetBlocks(accountInfo?.level)! - - (accountInfo?.blocksMinted + accountInfo?.blocksMintedAdjustment); - - const countDays = countBlocks / averageBlockDay(adminInfo, nodeHeightBlock); + (accountInfo?.blocksMinted + accountInfo?.blocksMintedAdjustment) + 1000; + + const countBlocksActual = countBlocks + nextBatch - (countBlocks % 1000); + const countDays = countBlocksActual / averageBlockDay(adminInfo, nodeHeightBlock); return countDays; };