diff --git a/.changeset/spotty-moons-vanish.md b/.changeset/spotty-moons-vanish.md
new file mode 100644
index 000000000..1b0eab7e3
--- /dev/null
+++ b/.changeset/spotty-moons-vanish.md
@@ -0,0 +1,5 @@
+---
+'explorer': minor
+---
+
+Use explored for host metrics.
diff --git a/apps/explorer/app/page.tsx b/apps/explorer/app/page.tsx
index 189d1ec3e..eade37132 100644
--- a/apps/explorer/app/page.tsx
+++ b/apps/explorer/app/page.tsx
@@ -6,6 +6,7 @@ import { humanBytes } from '@siafoundation/units'
import { getLatestBlocks } from '../lib/blocks'
import { siaCentral } from '../config/siaCentral'
import { to } from '@siafoundation/request'
+import { explored } from '../config/explored'
export function generateMetadata(): Metadata {
const title = 'siascan'
@@ -24,11 +25,11 @@ export const revalidate = 0
export default async function HomePage() {
const [
- [metrics, metricsError],
[exchangeRates, exchangeRatesError],
[hosts, hostsError],
+ [hostMetrics, hostMetricsError],
+ [blockMetrics, blockMetricsError],
] = await Promise.all([
- to(siaCentral.hostsNetworkMetrics()),
to(
siaCentral.exchangeRates({
params: { currencies: 'sc' },
@@ -41,14 +42,21 @@ export default async function HomePage() {
},
})
),
+ to(explored.hostMetrics()),
+ to(explored.blockMetrics()),
])
const [latestBlocks, latestBlocksError] = await getLatestBlocks()
const latestHeight = latestBlocks ? latestBlocks[0].height : 0
- if (metricsError || latestBlocksError || exchangeRatesError || hostsError) {
+ if (
+ latestBlocksError ||
+ exchangeRatesError ||
+ hostsError ||
+ hostMetricsError ||
+ blockMetricsError
+ ) {
console.log(new Date().toISOString(), {
- metricsError,
latestBlocksError,
exchangeRatesError,
hostsError,
@@ -56,7 +64,6 @@ export default async function HomePage() {
}
console.log(new Date().toISOString(), {
- metrics: humanBytes(Buffer.byteLength(JSON.stringify(metrics || ''))),
latestBlocks: humanBytes(
Buffer.byteLength(JSON.stringify(latestBlocks || ''))
),
@@ -64,15 +71,22 @@ export default async function HomePage() {
Buffer.byteLength(JSON.stringify(exchangeRates || ''))
),
hosts: humanBytes(Buffer.byteLength(JSON.stringify(hosts || ''))),
+ hostMetrics: humanBytes(
+ Buffer.byteLength(JSON.stringify(hostMetrics || ''))
+ ),
+ blockMetrics: humanBytes(
+ Buffer.byteLength(JSON.stringify(blockMetrics || ''))
+ ),
})
return (
)
}
diff --git a/apps/explorer/components/Home/index.tsx b/apps/explorer/components/Home/index.tsx
index bb00ab05e..86e21a363 100644
--- a/apps/explorer/components/Home/index.tsx
+++ b/apps/explorer/components/Home/index.tsx
@@ -13,7 +13,6 @@ import { reverse, sortBy } from '@technically/lodash'
import {
SiaCentralExchangeRates,
SiaCentralHost,
- SiaCentralHostsNetworkMetricsResponse,
} from '@siafoundation/sia-central-types'
import { hashToAvatar } from '../../lib/avatar'
import {
@@ -26,7 +25,7 @@ import {
import { HostListItem } from './HostListItem'
import { useExchangeRate } from '../../hooks/useExchangeRate'
import { SiaCentralHostScanned } from '../Host/types'
-import { ExplorerBlock } from '@siafoundation/explored-types'
+import { ExplorerBlock, HostMetrics } from '@siafoundation/explored-types'
export function Home({
metrics,
@@ -34,12 +33,14 @@ export function Home({
blocks,
hosts,
rates,
+ totalHosts,
}: {
- metrics?: SiaCentralHostsNetworkMetricsResponse
+ metrics?: HostMetrics
blockHeight: number
blocks: ExplorerBlock[]
hosts: SiaCentralHost[]
rates?: SiaCentralExchangeRates
+ totalHosts?: number
}) {
const exchange = useExchangeRate(rates)
const values = useMemo(() => {
@@ -67,8 +68,7 @@ export function Home({
{humanBytes(
- metrics?.totals.total_storage -
- metrics?.totals.remaining_storage
+ metrics?.totalStorage - metrics?.remainingStorage
)}
- {humanBytes(metrics?.totals.total_storage)}
+ {humanBytes(metrics?.totalStorage)}
@@ -104,12 +101,12 @@ export function Home({
weight="semibold"
color="contrast"
>
- {humanNumber(metrics?.totals.active_hosts)}
+ {humanNumber(metrics?.activeHosts)}
- {humanNumber(metrics?.totals.total_hosts)}
+ {humanNumber(totalHosts)}
@@ -126,13 +123,13 @@ export function Home({
color="contrast"
>
{getStorageCost({
- price: metrics?.average.settings.storage_price,
+ price: metrics?.settings.storageprice,
exchange,
})}
{getStorageCost({
- price: metrics?.average.settings.storage_price,
+ price: metrics?.settings.storageprice,
})}
@@ -150,13 +147,13 @@ export function Home({
color="contrast"
>
{getDownloadCost({
- price: metrics?.average.settings.download_price,
+ price: metrics?.priceTable.downloadbandwidthcost,
exchange,
})}
{getDownloadCost({
- price: metrics?.average.settings.download_price,
+ price: metrics?.priceTable.downloadbandwidthcost,
})}
@@ -174,13 +171,13 @@ export function Home({
color="contrast"
>
{getUploadCost({
- price: metrics?.average.settings.upload_price,
+ price: metrics?.priceTable.uploadbandwidthcost,
exchange,
})}
{getUploadCost({
- price: metrics?.average.settings.upload_price,
+ price: metrics?.priceTable.uploadbandwidthcost,
})}
@@ -190,7 +187,7 @@ export function Home({
)
}
return list
- }, [metrics, blockHeight, exchange])
+ }, [metrics, blockHeight, exchange, totalHosts])
return (