Neptune-Crypto / neptune-core

anonymous peer-to-peer cash
Apache License 2.0
23 stars 7 forks source link

Feature : Get CPU temperature over the RPC #139

Closed elielnfinic closed 1 month ago

elielnfinic commented 2 months ago

Addresses : #138.

Description:

This pull request introduces the implementation of the get_cpu_temps method, which retrieves the CPU temperature for use in the dashboard. This feature leverages the systemstat library.

The get_cpu_temps method is located in/src/rpc_server.rs to facilitate its use via the RPC server.

It's important to note that the systemstat library does not support CPU temperature retrieval on Silicon Macs, as Apple has disabled this feature. Consequently, the associated test is designed to expect a None result when running on macOS.

As in /src/bin/dashboard_src/overview_screen.rs, cpu_temperature is a Option, I converted the f32 we get from systemstat into f64.

Sword-Smith commented 2 months ago

Thanks for adding a test. PRs that introduce new tests make me happy :)

Your PR introduces a compiler warning. Can you fix that? I personally run make all to check that there are no bugs/compiler warnings but if you don't have a powerful machine, maybe you just want to run cargo clippy --all-targets and cargo fmt --all --check instead.

warning: unused variable: `state_lock`
    --> src/rpc_server.rs:1114:26
     |
1114 |         let (rpc_server, state_lock) =
     |                          ^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_state_lock`
     |
     = note: `#[warn(unused_variables)]` on by default
elielnfinic commented 2 months ago

Thanks @Sword-Smith for your review. I will fix that quickly.

Sword-Smith commented 1 month ago

Thank you for your contribution, @elielnfinic. The PR was merged manually through CLI by me. You have of course been credited :)

Sword-Smith commented 1 month ago

Merged through CLI.