Skip to content

Commit

Permalink
added DEFAULT_ETH_FAUCET_ADDRESS
Browse files Browse the repository at this point in the history
  • Loading branch information
prekucki committed Jul 28, 2020
1 parent 31ac396 commit a57d177
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions core/payment-driver/src/gnt/faucet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ const MAX_ETH_FAUCET_REQUESTS: u32 = 6;
const ETH_FAUCET_SLEEP: time::Duration = time::Duration::from_secs(2);
const INIT_ETH_SLEEP: time::Duration = time::Duration::from_secs(15);
const ETH_FAUCET_ADDRESS_ENV_VAR: &str = "ETH_FAUCET_ADDRESS";
const DEFAULT_ETH_FAUCET_ADDRESS: &str = "http://faucet.testnet.golem.network:4000/donate";

pub struct EthFaucetConfig {
faucet_address: awc::http::Uri,
}

impl EthFaucetConfig {
pub fn from_env() -> PaymentDriverResult<Self> {
let faucet_address_str = env::var(ETH_FAUCET_ADDRESS_ENV_VAR).map_err(|_| {
PaymentDriverError::MissingEnvironmentVariable(ETH_FAUCET_ADDRESS_ENV_VAR)
})?;
let faucet_address_str = env::var(ETH_FAUCET_ADDRESS_ENV_VAR)
.ok()
.unwrap_or_else(|| DEFAULT_ETH_FAUCET_ADDRESS.to_string());
let faucet_address = faucet_address_str.parse().map_err(|e| {
PaymentDriverError::LibraryError(format!("invalid faucet address: {}", e))
})?;
Expand Down

0 comments on commit a57d177

Please sign in to comment.