Skip to content

Commit

Permalink
added some logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Gianmarco Fraccaroli committed Feb 14, 2024
1 parent cb31424 commit 3954aae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/handler/faucet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub async fn request_challenge(
State(mut state): State<FaucetState>,
Path(player_id): Path<String>,
) -> Result<Json<FaucetResponseDto>, ApiError> {
tracing::info!("Challenge request from {}",player_id);
let client = reqwest::Client::new();
let req = client
.get(format!(
Expand Down Expand Up @@ -79,10 +80,13 @@ pub async fn request_challenge(
};

if too_many_requests {
tracing::info!("Challenge request from {}, was not accepted (too many reqs)", player_id);
return Err(FaucetError::TooManyRequests.into());
}
state.last_requests.insert(player_id.clone(), now);

tracing::info!("Challenge request from {}, was accepted", player_id);

let faucet_request = state
.faucet_service
.generate_faucet_request(state.auth_key, player_id)
Expand All @@ -97,6 +101,8 @@ pub async fn request_transfer(
State(mut state): State<FaucetState>,
ValidatedRequest(payload): ValidatedRequest<FaucetRequestDto>,
) -> Result<Json<FaucetResponseStatusDto>, ApiError> {
tracing::info!("Faucet request from {} is asking for {}", payload.player_id, payload.transfer.amount);

let auth_key: String = state.auth_key.clone();

if payload.transfer.amount > state.withdraw_limit {
Expand Down Expand Up @@ -228,6 +234,7 @@ pub async fn request_transfer(
};

if transfer_result {
tracing::info!("Faucet request from {} for {} was succesful", payload.player_id, payload.transfer.amount);
state.faucet_repo.add(payload.challenge.clone()).await;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async fn main() -> anyhow::Result<()> {
let db = Arc::new(RwLock::new(AppState::default()));

tracing_subscriber::fmt()
.with_max_level(tracing::Level::INFO)
.with_max_level(tracing::Level::DEBUG)
.init();

ApplicationServer::serve(config, db)
Expand Down

0 comments on commit 3954aae

Please sign in to comment.