Refactor functions

This commit is contained in:
Nicola Benaglia 2025-06-21 13:29:42 +02:00
parent 479ebefd63
commit 4afac86b66

View File

@ -183,7 +183,7 @@ export const countReward = (
nodeStatus, nodeStatus,
tier4Online: number tier4Online: number
): number => { ): number => {
if (accountInfo != null) { if (accountInfo != null && (addressLevel && addressLevel.length > 0) ) {
const level = accountInfo.level; const level = accountInfo.level;
if (level === 0) { if (level === 0) {
return 0; return 0;
@ -273,7 +273,7 @@ export const countRewardDay = (
nodeStatus, nodeStatus,
tier4Online: number tier4Online: number
): number => { ): number => {
if (accountInfo != null) { if (accountInfo != null && (addressLevel && addressLevel.length > 0) ) {
const level = accountInfo.level; const level = accountInfo.level;
const timeCalc = averageBlockDay(adminInfo, nodeHeightBlock); const timeCalc = averageBlockDay(adminInfo, nodeHeightBlock);
if (level === 0) { if (level === 0) {
@ -426,11 +426,12 @@ export const levelUpBlocks = (accountInfo, nodeStatus): number => {
) )
return 0; return 0;
const nextBatch = 1000 - (nodeStatus.height % 1000);
const countBlocks = const countBlocks =
accountTargetBlocks(accountInfo?.level)! - accountTargetBlocks(accountInfo?.level)! -
(accountInfo?.blocksMinted + accountInfo?.blocksMintedAdjustment); (accountInfo?.blocksMinted + accountInfo?.blocksMintedAdjustment) + 1000;
const countBlocksActual = countBlocks + nextBatch - (countBlocks % 1000);
return countBlocks; return countBlocksActual;
}; };
export const levelUpDays = ( export const levelUpDays = (
@ -446,11 +447,13 @@ export const levelUpDays = (
) )
return undefined; return undefined;
const nextBatch = 1000 - (nodeStatus.height % 1000);
const countBlocks = const countBlocks =
accountTargetBlocks(accountInfo?.level)! - accountTargetBlocks(accountInfo?.level)! -
(accountInfo?.blocksMinted + accountInfo?.blocksMintedAdjustment); (accountInfo?.blocksMinted + accountInfo?.blocksMintedAdjustment) + 1000;
const countDays = countBlocks / averageBlockDay(adminInfo, nodeHeightBlock); const countBlocksActual = countBlocks + nextBatch - (countBlocks % 1000);
const countDays = countBlocksActual / averageBlockDay(adminInfo, nodeHeightBlock);
return countDays; return countDays;
}; };