Skip to content

Commit

Permalink
Merge pull request #22 from cardano-scaling/pi/game-id
Browse files Browse the repository at this point in the history
Return the node ID in the new game response
  • Loading branch information
Quantumplation authored Nov 8, 2024
2 parents 277ff0f + de557a3 commit 023702e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/routes/new_game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::model::cluster::{ClusterState, NodeClient};

#[derive(Serialize)]
pub struct NewGameResponse {
game_id: String,
ip: String,
player_state: String,
}
Expand All @@ -23,13 +24,13 @@ pub async fn new_game(address: &str, state: &State<ClusterState>) -> Result<Json
};

let node = state.get_warm_node().context("error getting warm node")?;

info!(id = &node.metadata.name, "select node for new game");
let node_id = node.metadata.name.clone().expect("node without a name");
info!(id = node_id, "select node for new game");

let client =
NodeClient::new(node, state.admin_sk.clone(), true).context("error connecting to node")?;

info!(id = &client.resource.metadata.name, "connected to node");
info!(id = node_id, "connected to node");

let tx_hash = client
.new_game(pkh)
Expand All @@ -44,6 +45,7 @@ pub async fn new_game(address: &str, state: &State<ClusterState>) -> Result<Json
.unwrap_or_default();

Ok(Json(NewGameResponse {
game_id: node_id,
ip,
player_state: format!("{}#1", hex::encode(tx_hash)),
}))
Expand Down

0 comments on commit 023702e

Please sign in to comment.