Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion mujina-miner/src/api/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ impl SharedState {
.lock()
.unwrap_or_else(|e| e.into_inner())
.boards();
state.hashrate = state
.boards
.iter()
.flat_map(|board| board.threads.iter())
.map(|thread| thread.hashrate)
.sum();
state
}
}
Expand Down Expand Up @@ -136,7 +142,7 @@ mod tests {

use super::*;
use crate::api::commands::SchedulerCommand;
use crate::api_client::types::{BoardState, SourceState};
use crate::api_client::types::{BoardState, SourceState, ThreadState};
use crate::board::BoardRegistration;

/// Test fixtures returned by the router builder.
Expand Down Expand Up @@ -205,6 +211,11 @@ mod tests {
let board = BoardState {
name: "test-board".into(),
model: "TestModel".into(),
threads: vec![ThreadState {
name: "thread-0".into(),
hashrate: 1_000_000,
is_active: true,
}],
..Default::default()
};
let fixtures = build_test_router(miner_state, vec![board]);
Expand Down
21 changes: 21 additions & 0 deletions mujina-miner/src/api_client/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,33 @@ pub struct BoardState {
pub name: String,
pub model: String,
pub serial: Option<String>,
/// Configured board operating frequency in MHz, if known.
pub frequency_mhz: Option<f32>,
/// Number of hashboard channels exposed by this board, if known.
pub hashboard_count: Option<u8>,
/// Number of hashboard channels currently active in Mujina, if known.
pub active_hashboard_count: Option<u8>,
pub fans: Vec<Fan>,
pub hashboards: Vec<HashboardState>,
pub temperatures: Vec<TemperatureSensor>,
pub powers: Vec<PowerMeasurement>,
pub threads: Vec<ThreadState>,
}

/// Per-hashboard connectivity and activity state.
#[derive(Clone, Debug, Deserialize, Serialize, ToSchema)]
pub struct HashboardState {
pub index: u8,
/// Serial port assigned to this hashboard data channel, if known.
pub serial_port: Option<String>,
/// Whether the bridge currently detects a hashboard on this channel.
pub is_present: bool,
/// Whether Mujina has started a worker thread for this channel.
pub is_active: bool,
/// Hashrate in hashes per second for this hashboard.
pub hashrate: u64,
}

/// Fan status.
#[derive(Clone, Debug, Deserialize, Serialize, ToSchema)]
pub struct Fan {
Expand Down
5 changes: 5 additions & 0 deletions mujina-miner/src/asic/bm13xx/chain_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ pub struct ChainPeripherals {

/// Voltage regulator control (optional, may be shared across chains).
pub voltage_regulator: Option<Arc<Mutex<dyn VoltageRegulator + Send>>>,

/// Serializes full cold-start initialization when multiple chains share
/// board-level control hardware such as a PSU or reset/control bridge.
pub initialization_lock: Arc<Mutex<()>>,
}

#[cfg(test)]
Expand Down Expand Up @@ -111,6 +115,7 @@ mod tests {
let peripherals = ChainPeripherals {
asic_enable: enable,
voltage_regulator: None,
initialization_lock: Arc::new(Mutex::new(())),
};

// Hash thread enables
Expand Down
Loading