Skip to content

Commit

Permalink
fix(faucet): rate limit before getting wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuef committed Apr 25, 2024
1 parent 27b8781 commit 7868362
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions sn_faucet/src/faucet_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ async fn respond_to_donate_request(
) -> std::result::Result<impl Reply, std::convert::Infallible> {
let faucet_root = get_faucet_data_dir();

let permit = semaphore.try_acquire();
info!("Got donate request with: {transfer_str}");

let mut wallet = match load_account_wallet_or_create_with_mnemonic(&faucet_root, None) {
Ok(wallet) => wallet,
Err(_error) => {
Expand All @@ -142,8 +145,6 @@ async fn respond_to_donate_request(
return Ok(response);
}
};
let permit = semaphore.try_acquire();
info!("Got donate request with: {transfer_str}");

// some rate limiting
if is_wallet_locked() || permit.is_err() {
Expand Down

0 comments on commit 7868362

Please sign in to comment.