diff --git a/src/pages/Home/Banner/index.tsx b/src/pages/Home/Banner/index.tsx index bab0e05cc..22611a0bf 100644 --- a/src/pages/Home/Banner/index.tsx +++ b/src/pages/Home/Banner/index.tsx @@ -8,13 +8,14 @@ const { BACKUP_NODES: backupNodes } = config export default () => { const { data: size } = useQuery( - ['backup_nodes'], + ['backnode_tip_header'], async () => { try { if (backupNodes.length === 0) return null - const [size1, size2] = await Promise.race(backupNodes.map(getKnowledgeSize)) - return size1 ?? size2 + const size = await Promise.race(backupNodes.map(getKnowledgeSize)) + + return size } catch { return null } diff --git a/src/pages/Home/Banner/utils.ts b/src/pages/Home/Banner/utils.ts index c2df57ef5..7edbad234 100644 --- a/src/pages/Home/Banner/utils.ts +++ b/src/pages/Home/Banner/utils.ts @@ -1,3 +1,4 @@ +import { ckbDecimals } from '@ckb-lumos/bi' import BigNumber from 'bignumber.js' /** @@ -5,6 +6,7 @@ import BigNumber from 'bignumber.js' * ref: https://talk.nervos.org/t/how-to-get-the-average-occupied-bytes-per-live-cell-in-ckb/7138/2?u=keith * */ const EXCLUDE = BigNumber('504000000000000000') +const CKB_DECIMAL = BigNumber(10).pow(ckbDecimals) export const getKnowledgeSize = async (nodeUrl: string) => { const header = await fetch(nodeUrl, { @@ -25,6 +27,6 @@ export const getKnowledgeSize = async (nodeUrl: string) => { .slice(2) .match(/\w{16}/g) .map((i: string) => i.match(/\w{2}/g)?.reverse().join('') ?? '') - const total = BigNumber(`0x${u}`).minus(EXCLUDE).toFormat() + const total = BigNumber(`0x${u}`).minus(EXCLUDE).div(CKB_DECIMAL).toNumber() return total }