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:
Tyera Eulberg
2021-04-06 01:01:05 -06:00
committed by GitHub
parent 1219842a96
commit 03d3ae1cb9
13 changed files with 425 additions and 244 deletions

View File

@@ -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;