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