Skip to content

Commit

Permalink
Fix gpuminer initialization
Browse files Browse the repository at this point in the history
The GPU miner hardware monitor was being initialized too early causing
the app never to recognize the gpu miner later on. Fix the
initialization sequence, and only append the gpu miner data to telemetry
on demand instead of on telemetry initialization.
  • Loading branch information
brianp committed Jan 15, 2025
1 parent 84ef27d commit 6397126
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
21 changes: 11 additions & 10 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,16 +239,6 @@ async fn setup_inner(
let last_binaries_update_timestamp = state.config.read().await.last_binaries_update_timestamp();
let now = SystemTime::now();

let _unused = state
.gpu_miner
.write()
.await
.detect(config_dir.clone())
.await
.inspect_err(|e| error!(target: LOG_TARGET, "Could not detect gpu miner: {:?}", e));

HardwareStatusMonitor::current().initialize().await?;

state
.telemetry_manager
.write()
Expand Down Expand Up @@ -457,6 +447,17 @@ async fn setup_inner(
//drop binary resolver to release the lock
drop(binary_resolver);

let _unused = state
.gpu_miner
.write()
.await
.detect(config_dir.clone())
.await
.inspect_err(|e| error!(target: LOG_TARGET, "Could not detect gpu miner: {:?}", e));

HardwareStatusMonitor::current().initialize().await?;


let mut tor_control_port = None;
if use_tor && !cfg!(target_os = "macos") {
state
Expand Down
16 changes: 8 additions & 8 deletions src-tauri/src/telemetry_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,6 @@ impl TelemetryService {
Some(cpu) => cpu.public_properties.name.clone(),
None => "Unknown".to_string(),
};
let gpu_name = hardware.get_gpu_devices().await?;
let gpu_name = match gpu_name.first() {
Some(gpu) => gpu.public_properties.name.clone(),
None => "Unknown".to_string(),
};
let os = PlatformUtils::detect_current_os();

self.version = app_version;
Expand All @@ -130,7 +125,6 @@ impl TelemetryService {
version,
user_id: user,
cpu_name,
gpu_name,
os,
};
tokio::select! {
Expand Down Expand Up @@ -196,7 +190,6 @@ struct SystemInfo {
user_id: String,
os: CurrentOperatingSystem,
cpu_name: String,
gpu_name: String,
}

async fn send_telemetry_data(
Expand All @@ -206,6 +199,13 @@ async fn send_telemetry_data(
) -> Result<(), TelemetryServiceError> {
let request = reqwest::Client::new();

let hardware = HardwareStatusMonitor::current();
let gpu_name = hardware.get_gpu_devices().await?;
let gpu_name = match gpu_name.first() {
Some(gpu) => gpu.public_properties.name.clone(),
None => "Unknown".to_string(),
};

let full_data = FullTelemetryData {
event_name: data.event_name,
event_value: data.event_value,
Expand All @@ -215,7 +215,7 @@ async fn send_telemetry_data(
version: system_info.version,
os: system_info.os.to_string(),
cpu_name: system_info.cpu_name,
gpu_name: system_info.gpu_name,
gpu_name,
};
let request_builder = request
.post(api_url)
Expand Down

0 comments on commit 6397126

Please sign in to comment.