-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from fedimint/v0.4.3
- Loading branch information
Showing
33 changed files
with
690 additions
and
682 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
31 changes: 6 additions & 25 deletions
31
fedimint-clientd/src/router/handlers/admin/discover_version.rs
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,51 +1,32 @@ | ||
use std::collections::HashMap; | ||
|
||
use axum::extract::State; | ||
use axum::http::StatusCode; | ||
use axum::Json; | ||
use multimint::MultiMint; | ||
use serde::Deserialize; | ||
use serde_json::{json, Value}; | ||
|
||
use crate::error::AppError; | ||
use crate::state::AppState; | ||
|
||
#[derive(Debug, Clone, Deserialize)] | ||
pub struct DiscoverVersionRequest { | ||
threshold: Option<usize>, | ||
} | ||
|
||
async fn _discover_version( | ||
multimint: MultiMint, | ||
threshold: Option<usize>, | ||
) -> Result<Value, AppError> { | ||
async fn _discover_version(multimint: MultiMint) -> Result<Value, AppError> { | ||
let mut api_versions = HashMap::new(); | ||
for (id, client) in multimint.clients.lock().await.iter() { | ||
api_versions.insert( | ||
*id, | ||
json!({"version" : client.discover_common_api_version(threshold).await?}), | ||
json!({"version" : client.load_and_refresh_common_api_version().await?}), | ||
); | ||
} | ||
Ok(json!(api_versions)) | ||
} | ||
|
||
pub async fn handle_ws(state: AppState, v: Value) -> Result<Value, AppError> { | ||
let v = serde_json::from_value::<DiscoverVersionRequest>(v).map_err(|e| { | ||
AppError::new( | ||
StatusCode::BAD_REQUEST, | ||
anyhow::anyhow!("Invalid request: {}", e), | ||
) | ||
})?; | ||
let version = _discover_version(state.multimint, v.threshold).await?; | ||
pub async fn handle_ws(state: AppState) -> Result<Value, AppError> { | ||
let version = _discover_version(state.multimint).await?; | ||
let version_json = json!(version); | ||
Ok(version_json) | ||
} | ||
|
||
#[axum_macros::debug_handler] | ||
pub async fn handle_rest( | ||
State(state): State<AppState>, | ||
Json(req): Json<DiscoverVersionRequest>, | ||
) -> Result<Json<Value>, AppError> { | ||
let version = _discover_version(state.multimint, req.threshold).await?; | ||
pub async fn handle_rest(State(state): State<AppState>) -> Result<Json<Value>, AppError> { | ||
let version = _discover_version(state.multimint).await?; | ||
Ok(Json(version)) | ||
} |
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
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
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
Oops, something went wrong.