asic_rs/data/
miner.rs

1use crate::data::deserialize::deserialize_macaddr;
2use crate::data::serialize::serialize_macaddr;
3use crate::data::serialize::serialize_power;
4use crate::data::serialize::serialize_temperature;
5use std::{net::IpAddr, time::Duration};
6
7use super::{
8    board::BoardData, device::DeviceInfo, fan::FanData, hashrate::HashRate, message::MinerMessage,
9    pool::PoolData,
10};
11use macaddr::MacAddr;
12use measurements::{Power, Temperature};
13use serde::{Deserialize, Serialize};
14
15#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
16pub struct MinerData {
17    /// The schema version of this MinerData object, for use in external APIs
18    pub schema_version: String,
19    /// The time this data was gathered and constructed
20    pub timestamp: u64,
21    /// The IP address of the miner this data is for
22    pub ip: IpAddr,
23    /// The MAC address of the miner this data is for
24    #[serde(
25        serialize_with = "serialize_macaddr",
26        deserialize_with = "deserialize_macaddr"
27    )]
28    pub mac: Option<MacAddr>,
29    /// Hardware information about this miner
30    pub device_info: DeviceInfo,
31    /// The serial number of the miner, also known as the control board serial
32    pub serial_number: Option<String>,
33    /// The network hostname of the miner
34    pub hostname: Option<String>,
35    /// The API version of the miner
36    pub api_version: Option<String>,
37    /// The firmware version of the miner
38    pub firmware_version: Option<String>,
39    /// The type of control board on the miner
40    pub control_board_version: Option<String>,
41    /// The expected number of boards in the miner.
42    pub expected_hashboards: Option<u8>,
43    /// Per-hashboard data for this miner
44    pub hashboards: Vec<BoardData>,
45    /// The current hashrate of the miner
46    pub hashrate: Option<HashRate>,
47    /// The expected hashrate of the miner
48    pub expected_hashrate: Option<HashRate>,
49    /// The total expected number of chips across all boards on this miner
50    pub expected_chips: Option<u16>,
51    /// The total number of working chips across all boards on this miner
52    pub total_chips: Option<u16>,
53    /// The expected number of fans on the miner
54    pub expected_fans: Option<u8>,
55    /// The current fan information for the miner
56    pub fans: Vec<FanData>,
57    /// The current PDU fan information for the miner
58    pub psu_fans: Vec<FanData>,
59    /// The average temperature across all chips in the miner
60    #[serde(serialize_with = "serialize_temperature")]
61    pub average_temperature: Option<Temperature>,
62    /// The environment temperature of the miner, such as air temperature or immersion fluid temperature
63    #[serde(serialize_with = "serialize_temperature")]
64    pub fluid_temperature: Option<Temperature>,
65    /// The current power consumption of the miner
66    #[serde(serialize_with = "serialize_power")]
67    pub wattage: Option<Power>,
68    /// The current power limit or power target of the miner
69    #[serde(serialize_with = "serialize_power")]
70    pub wattage_limit: Option<Power>,
71    /// The current efficiency in W/TH/s (J/TH) of the miner
72    pub efficiency: Option<f64>,
73    /// The state of the fault/alert light on the miner
74    pub light_flashing: Option<bool>,
75    /// Any message on the miner, including errors
76    pub messages: Vec<MinerMessage>,
77    /// The total uptime of the miner's system
78    pub uptime: Option<Duration>,
79    /// Whether the hashing process is currently running
80    pub is_mining: bool,
81    /// The current pools configured on the miner
82    pub pools: Vec<PoolData>,
83}