forked from stringhandler/tarigpuminer
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
388 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
/target | ||
config.json | ||
data | ||
|
||
# Ignore OS files | ||
.DS_Store | ||
.idea/ | ||
.vscode/* | ||
!.vscode/extensions.json | ||
!.vscode/extensions.json |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,27 @@ | ||
use std::collections::HashMap; | ||
|
||
use axum::{extract::State, http::StatusCode, Json}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::http::server::AppState; | ||
use crate::http::{ | ||
server::AppState, | ||
stats_collector::{AverageHashrate, GetHashrateResponse}, | ||
}; | ||
|
||
#[derive(Serialize, Deserialize)] | ||
#[derive(Serialize)] | ||
pub struct Stats { | ||
pub hashes_per_second: u64, | ||
pub accepted_blocks: u64, | ||
pub rejected_blocks: u64, | ||
hashrate_per_device: HashMap<u32, AverageHashrate>, | ||
total_hashrate: AverageHashrate, | ||
} | ||
|
||
pub async fn handle_get_stats(State(state): State<AppState>) -> Result<Json<Stats>, StatusCode> { | ||
Ok(Json(Stats { | ||
hashes_per_second: state.stats_store.hashes_per_second(), | ||
accepted_blocks: state.stats_store.accepted_blocks(), | ||
rejected_blocks: state.stats_store.rejected_blocks(), | ||
})) | ||
let hashrate = state.stats_client.get_hashrate().await.map_err(|e| { | ||
log::error!("Failed to get hashrate: {:?}", e); | ||
StatusCode::INTERNAL_SERVER_ERROR | ||
})?; | ||
let stats = Stats { | ||
hashrate_per_device: hashrate.devices, | ||
total_hashrate: hashrate.total, | ||
}; | ||
Ok(Json(stats)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod config; | ||
mod handlers; | ||
pub mod server; | ||
pub mod stats_collector; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.