Faucet: repurpose cap and slice args to apply to single IPs (#16381)
* Single use stmt * Log request IP * Switch cap and slice to apply per IP * Use SOL in logs, error msgs * Use thiserror instead of overloading io::Error * Return memo transaction for requests that exceed per-request-cap * Handle faucet memos in cli * Add some docs, esp about memo transaction * Use SOL symbol & standardize memo Co-authored-by: Michael Vines <mvines@gmail.com> * Differentiate faucet tx-length errors * Populate signature in cli airdrop memo case Co-authored-by: Michael Vines <mvines@gmail.com>
This commit is contained in:
@@ -1,14 +1,17 @@
|
||||
use clap::{crate_description, crate_name, App, Arg};
|
||||
use solana_clap_utils::input_parsers::{lamports_of_sol, value_of};
|
||||
use solana_faucet::{
|
||||
faucet::{run_faucet, Faucet, FAUCET_PORT},
|
||||
socketaddr,
|
||||
};
|
||||
use solana_sdk::signature::read_keypair_file;
|
||||
use std::{
|
||||
net::{Ipv4Addr, SocketAddr},
|
||||
sync::{Arc, Mutex},
|
||||
thread,
|
||||
use {
|
||||
clap::{crate_description, crate_name, App, Arg},
|
||||
log::*,
|
||||
solana_clap_utils::input_parsers::{lamports_of_sol, value_of},
|
||||
solana_faucet::{
|
||||
faucet::{run_faucet, Faucet, FAUCET_PORT},
|
||||
socketaddr,
|
||||
},
|
||||
solana_sdk::signature::read_keypair_file,
|
||||
std::{
|
||||
net::{Ipv4Addr, SocketAddr},
|
||||
sync::{Arc, Mutex},
|
||||
thread,
|
||||
},
|
||||
};
|
||||
|
||||
#[tokio::main]
|
||||
@@ -74,7 +77,8 @@ async fn main() {
|
||||
thread::spawn(move || loop {
|
||||
let time = faucet1.lock().unwrap().time_slice;
|
||||
thread::sleep(time);
|
||||
faucet1.lock().unwrap().clear_request_count();
|
||||
debug!("clearing ip cache");
|
||||
faucet1.lock().unwrap().clear_ip_cache();
|
||||
});
|
||||
|
||||
run_faucet(faucet, faucet_addr, None).await;
|
||||
|
Reference in New Issue
Block a user