Skip to content

Commit

Permalink
chore: add default faucet socket constant
Browse files Browse the repository at this point in the history
  • Loading branch information
zilayo committed Sep 15, 2024
1 parent 706be15 commit cc98ca6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions faucet/src/faucet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ macro_rules! socketaddr {
const ERROR_RESPONSE: [u8; 2] = 0u16.to_le_bytes();

pub const TIME_SLICE: u64 = 60;
/// The default faucet port: `9900`
pub const FAUCET_PORT: u16 = 9900;
/// The default faucet socket: `127.0.0.1:9900`
pub const FAUCET_SOCKET: SocketAddr =
SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), FAUCET_PORT);

#[derive(Error, Debug)]
pub enum FaucetError {
Expand Down
4 changes: 2 additions & 2 deletions transaction-dos/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use {
program::ProgramCliCommand,
},
solana_client::transaction_executor::TransactionExecutor,
solana_faucet::faucet::{request_airdrop_transaction, FAUCET_PORT},
solana_faucet::faucet::{request_airdrop_transaction, FAUCET_SOCKET},
solana_gossip::gossip_service::discover,
solana_rpc_client::rpc_client::RpcClient,
solana_sdk::{
Expand Down Expand Up @@ -550,7 +550,7 @@ fn main() {
exit(1)
});
}
let mut faucet_addr = SocketAddr::from((Ipv4Addr::LOCALHOST, FAUCET_PORT));
let mut faucet_addr = FAUCET_SOCKET;
if let Some(addr) = matches.value_of("faucet_addr") {
faucet_addr = solana_net_utils::parse_host_port(addr).unwrap_or_else(|e| {
eprintln!("failed to parse entrypoint address: {e}");
Expand Down
4 changes: 2 additions & 2 deletions validator/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use {
banking_trace::{DirByteLimit, BANKING_TRACE_DIR_DEFAULT_BYTE_LIMIT},
validator::{BlockProductionMethod, BlockVerificationMethod},
},
solana_faucet::faucet::{self, FAUCET_PORT},
solana_faucet::faucet::{self, FAUCET_SOCKET},
solana_ledger::use_snapshot_archives_at_startup,
solana_net_utils::{MINIMUM_VALIDATOR_PORT_RANGE_WIDTH, VALIDATOR_PORT_RANGE},
solana_rayon_threadlimit::get_thread_count,
Expand Down Expand Up @@ -2856,7 +2856,7 @@ impl DefaultTestArgs {
pub fn new() -> Self {
DefaultTestArgs {
rpc_port: rpc_port::DEFAULT_RPC_PORT.to_string(),
faucet_addr: format!("127.0.0.1:{FAUCET_PORT}"),
faucet_addr: format!("{}", FAUCET_SOCKET),
/* 10,000 was derived empirically by watching the size
* of the rocksdb/ directory self-limit itself to the
* 40MB-150MB range when running `solana-test-validator`
Expand Down

0 comments on commit cc98ca6

Please sign in to comment.