mirror of
https://github.com/Qortal/Qortal-Hub.git
synced 2025-06-24 08:31:20 +00:00
Add function, rename file
This commit is contained in:
parent
f28d66ddc7
commit
085df5e0a8
@ -42,8 +42,12 @@ import { useAtom, useSetAtom } from 'jotai';
|
||||
import { memberGroupsAtom, txListAtom } from '../../atoms/global';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { TransitionUp } from '../../common/Transitions.tsx';
|
||||
import { averageBlockDay, averageBlockTime, levelUpBlocks } from './Stats.tsx';
|
||||
import { node } from 'slate';
|
||||
import {
|
||||
averageBlockDay,
|
||||
averageBlockTime,
|
||||
dayReward,
|
||||
levelUpBlocks,
|
||||
} from './MintingStats.tsx';
|
||||
|
||||
export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
|
||||
const setTxList = useSetAtom(txListAtom);
|
||||
@ -187,6 +191,7 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
|
||||
const response = await fetch(url);
|
||||
const data = await response.json();
|
||||
setAdminInfo(data);
|
||||
setTimeout(getAdminInfo, 30000);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
@ -198,6 +203,7 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
|
||||
const response = await fetch(url);
|
||||
const data = await response.json();
|
||||
setNodeStatus(data);
|
||||
setTimeout(getNodeStatus, 30000);
|
||||
} catch (error) {
|
||||
console.error('Request failed', error);
|
||||
}
|
||||
@ -703,7 +709,11 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
|
||||
/>
|
||||
<StatCard
|
||||
label="Est. Reward Per Day"
|
||||
value="6.00782338 QORT"
|
||||
value={dayReward(
|
||||
adminInfo,
|
||||
nodeHeightBlock,
|
||||
nodeStatus
|
||||
).toFixed(2)}
|
||||
/>
|
||||
{/* <StatCard label="AdminInfo" value={adminInfo} /> */}
|
||||
</Grid>
|
||||
|
@ -1,10 +1,3 @@
|
||||
export const averageBlockDay = (adminInfo, nodeHeightBlock) => {
|
||||
const time = adminInfo.currentTimestamp - nodeHeightBlock.timestamp;
|
||||
const average: number = time / 1000 / 1440;
|
||||
const averageBlockDay = 86400 / average;
|
||||
return averageBlockDay;
|
||||
};
|
||||
|
||||
const accountTargetBlocks = (level: number) => {
|
||||
if (level === 0) {
|
||||
return 7200;
|
||||
@ -31,30 +24,75 @@ const accountTargetBlocks = (level: number) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const accountLevel = (level: number) => {
|
||||
export const accountLevel = (level: number): number => {
|
||||
if (level === 0) {
|
||||
return '1';
|
||||
return 1;
|
||||
} else if (level === 1) {
|
||||
return '2';
|
||||
return 2;
|
||||
} else if (level === 2) {
|
||||
return '3';
|
||||
return 3;
|
||||
} else if (level === 3) {
|
||||
return '4';
|
||||
return 4;
|
||||
} else if (level === 4) {
|
||||
return '5';
|
||||
return 5;
|
||||
} else if (level === 5) {
|
||||
return '6';
|
||||
return 6;
|
||||
} else if (level === 6) {
|
||||
return '7';
|
||||
return 7;
|
||||
} else if (level === 7) {
|
||||
return '8';
|
||||
return 8;
|
||||
} else if (level === 8) {
|
||||
return '9';
|
||||
return 9;
|
||||
} else if (level === 9) {
|
||||
return '10';
|
||||
return 10;
|
||||
} else {
|
||||
return 0; // fallback: should never reach this point
|
||||
}
|
||||
};
|
||||
|
||||
export const blockReward = (nodeStatus): number => {
|
||||
if (nodeStatus.height < 259201) {
|
||||
return 5.0;
|
||||
} else if (nodeStatus.height < 518401) {
|
||||
return 4.75;
|
||||
} else if (nodeStatus.height < 777601) {
|
||||
return 4.5;
|
||||
} else if (nodeStatus.height < 1036801) {
|
||||
return 4.25;
|
||||
} else if (nodeStatus.height < 1296001) {
|
||||
return 4.0;
|
||||
} else if (nodeStatus.height < 1555201) {
|
||||
return 3.75;
|
||||
} else if (nodeStatus.height < 1814401) {
|
||||
return 3.5;
|
||||
} else if (nodeStatus.height < 2073601) {
|
||||
return 3.25;
|
||||
} else if (nodeStatus.height < 2332801) {
|
||||
return 3.0;
|
||||
} else if (nodeStatus.height < 2592001) {
|
||||
return 2.75;
|
||||
} else if (nodeStatus.height < 2851201) {
|
||||
return 2.5;
|
||||
} else if (nodeStatus.height < 3110401) {
|
||||
return 2.25;
|
||||
} else {
|
||||
return 2.0;
|
||||
}
|
||||
};
|
||||
|
||||
export const averageBlockDay = (adminInfo, nodeHeightBlock) => {
|
||||
const time = adminInfo.currentTimestamp - nodeHeightBlock.timestamp;
|
||||
const average: number = time / 1000 / 1440;
|
||||
const averageBlockDay = 86400 / average;
|
||||
return averageBlockDay;
|
||||
};
|
||||
|
||||
export const averageBlockTime = (adminInfo, nodeHeightBlock) => {
|
||||
const avgBlockString = adminInfo.currentTimestamp - nodeHeightBlock.timestamp;
|
||||
const averageTimeString = avgBlockString / 1000 / 1440;
|
||||
return averageTimeString;
|
||||
};
|
||||
|
||||
export const levelUpBlocks = (accountInfo, nodeStatus) => {
|
||||
if (
|
||||
accountInfo?.blocksMinted === undefined ||
|
||||
@ -90,8 +128,8 @@ export const levelUpDays = (
|
||||
return countDays.toFixed(2);
|
||||
};
|
||||
|
||||
export const averageBlockTime = (adminInfo, nodeHeightBlock) => {
|
||||
const avgBlockString = adminInfo.currentTimestamp - nodeHeightBlock.timestamp;
|
||||
const averageTimeString = avgBlockString / 1000 / 1440;
|
||||
return averageTimeString;
|
||||
export const dayReward = (adminInfo, nodeHeightBlock, nodeStatus) => {
|
||||
const reward =
|
||||
averageBlockDay(adminInfo, nodeHeightBlock) * blockReward(nodeStatus);
|
||||
return reward;
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user