diff --git a/.changeset/shiny-onions-unite.md b/.changeset/shiny-onions-unite.md new file mode 100644 index 000000000..5e7a228a9 --- /dev/null +++ b/.changeset/shiny-onions-unite.md @@ -0,0 +1,5 @@ +--- +'hostd': minor +--- + +The contracts metrics now show active, rejected, failed, renewed, finalized, and successful. diff --git a/.changeset/spicy-boats-sneeze.md b/.changeset/spicy-boats-sneeze.md new file mode 100644 index 000000000..d9ecbbbfe --- /dev/null +++ b/.changeset/spicy-boats-sneeze.md @@ -0,0 +1,7 @@ +--- +'@siafoundation/hostd-types': minor +'@siafoundation/hostd-js': minor +'@siafoundation/hostd-react': minor +--- + +The metrics API types now include all available fields. diff --git a/.changeset/sweet-meals-flash.md b/.changeset/sweet-meals-flash.md new file mode 100644 index 000000000..7b6bd3cad --- /dev/null +++ b/.changeset/sweet-meals-flash.md @@ -0,0 +1,7 @@ +--- +'@siafoundation/hostd-types': minor +'@siafoundation/hostd-js': minor +'@siafoundation/hostd-react': minor +--- + +The metrics APIs now include wallet with balance and immatureBalance. Closes https://github.com/SiaFoundation/hostd/issues/450 diff --git a/apps/hostd/components/Home/HomeContracts.tsx b/apps/hostd/components/Home/HomeContracts.tsx index 9b2cefc7b..23477c7b3 100644 --- a/apps/hostd/components/Home/HomeContracts.tsx +++ b/apps/hostd/components/Home/HomeContracts.tsx @@ -34,6 +34,16 @@ export function HomeContracts() { isLoading={contracts.isLoading} enabledModes={['latest', 'average']} /> + v.toFixed(0)} + defaultMode="latest" + isLoading={contracts.isLoading} + enabledModes={['latest', 'average']} + /> ({ active: m.contracts.active, - failed: m.contracts.failed, - pending: m.contracts.pending, rejected: m.contracts.rejected, + failed: m.contracts.failed, + renewed: m.contracts.renewed, + finalized: m.contracts.finalized, successful: m.contracts.successful, timestamp: new Date(m.timestamp).getTime(), })) @@ -395,13 +396,28 @@ function useMetricsMain() { data, stats, config: { - enabledGraph: ['successful', 'active', 'pending', 'rejected', 'failed'], - enabledTip: ['successful', 'active', 'pending', 'rejected', 'failed'], + enabledGraph: [ + 'active', + 'rejected', + 'failed', + 'renewed', + 'finalized', + 'successful', + ], + enabledTip: [ + 'active', + 'rejected', + 'failed', + 'renewed', + 'finalized', + 'successful', + ], data: { active: chartConfigs.active, - failed: chartConfigs.failed, - pending: chartConfigs.pending, rejected: chartConfigs.rejected, + failed: chartConfigs.failed, + renewed: chartConfigs.renewed, + finalized: chartConfigs.finalized, successful: chartConfigs.successful, }, format: (v) => `${v} contracts`, diff --git a/apps/hostd/contexts/metrics/types.tsx b/apps/hostd/contexts/metrics/types.tsx index 56a2f0c84..bf07473e4 100644 --- a/apps/hostd/contexts/metrics/types.tsx +++ b/apps/hostd/contexts/metrics/types.tsx @@ -30,10 +30,11 @@ export type PricingKeys = | 'storage' export type ContractsKeys = - | 'failed' - | 'rejected' - | 'pending' | 'active' + | 'rejected' + | 'failed' + | 'renewed' + | 'finalized' | 'successful' export type StorageKeys = diff --git a/apps/hostd/contexts/transactions/index.tsx b/apps/hostd/contexts/transactions/index.tsx index be19acc83..a1acee10d 100644 --- a/apps/hostd/contexts/transactions/index.tsx +++ b/apps/hostd/contexts/transactions/index.tsx @@ -160,7 +160,7 @@ function useTransactionsMain() { (metrics.data || []) .map((t) => { return { - sc: Number(t.balance), + sc: Number(t.wallet.balance), timestamp: new Date(t.timestamp).getTime(), } }) diff --git a/libs/hostd-types/src/api.ts b/libs/hostd-types/src/api.ts index 7917d4ec3..b2de39e6f 100644 --- a/libs/hostd-types/src/api.ts +++ b/libs/hostd-types/src/api.ts @@ -231,27 +231,25 @@ type Revenue = { registryWrite: string } -// Data is a collection of metrics related to data usage. -type Data = { +type DataRHPMetrics = { // Ingress returns the number of bytes received by the host. ingress: number // Egress returns the number of bytes sent by the host. egress: number } -// Contracts is a collection of metrics related to contracts. -type Contracts = { - pending: number +type ContractMetrics = { active: number rejected: number failed: number + renewed: number + finalized: number successful: number lockedCollateral: string riskedCollateral: string } -// Pricing is a collection of metrics related to the host's pricing settings. -type Pricing = { +type PricingMetrics = { contractPrice: string ingressPrice: string egressPrice: string @@ -261,8 +259,7 @@ type Pricing = { collateralMultiplier: number } -// Registry is a collection of metrics related to the host's registry. -type Registry = { +type RegistryMetrics = { entries: number maxEntries: number @@ -270,35 +267,46 @@ type Registry = { writes: number } -// Storage is a collection of metrics related to storage. -type Storage = { +type StorageMetrics = { totalSectors: number physicalSectors: number + lostSectors: number contractSectors: number tempSectors: number reads: number writes: number + sectorCacheHits: number + sectorCacheMisses: number } -// RevenueMetrics is a collection of metrics related to revenue. type RevenueMetrics = { potential: Revenue earned: Revenue } -// DataMetrics is a collection of metrics related to data usage. type DataMetrics = { - rhp: Data + rhp: DataRHPMetrics +} + +type AccountMetrics = { + active: number + balance: string +} + +type WalletMetrics = { + balance: string + immatureBalance: string } export type Metrics = { + accounts: AccountMetrics revenue: RevenueMetrics - pricing: Pricing - contracts: Contracts - storage: Storage - registry: Registry + pricing: PricingMetrics + contracts: ContractMetrics + storage: StorageMetrics + registry: RegistryMetrics data: DataMetrics - balance: string + wallet: WalletMetrics timestamp: string }