Skip to content

Commit

Permalink
chore: move load_clientconfig_serverless changes to `load_clientcon…
Browse files Browse the repository at this point in the history
…fig`
  • Loading branch information
dorianvp committed Nov 26, 2024
1 parent f6be38c commit f62b8bf
Showing 1 changed file with 2 additions and 37 deletions.
39 changes: 2 additions & 37 deletions zingolib/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,43 +63,8 @@ pub fn margin_fee() -> u64 {
zcash_primitives::transaction::fees::zip317::MARGINAL_FEE.into_u64()
}

/// TODO: Add Doc Comment Here!
pub fn load_clientconfig(
lightwallet_uri: http::Uri,
data_dir: Option<PathBuf>,
chain: ChainType,
monitor_mempool: bool,
) -> std::io::Result<ZingoConfig> {
use std::net::ToSocketAddrs;
format!(
"{}:{}",
lightwallet_uri.host().unwrap(),
lightwallet_uri.port().unwrap()
)
.to_socket_addrs()?
.next()
.ok_or(std::io::Error::new(
ErrorKind::ConnectionRefused,
"Couldn't resolve server!",
))?;

// Create a Light Client Config
let config = ZingoConfig {
lightwalletd_uri: Arc::new(RwLock::new(lightwallet_uri)),
chain,
monitor_mempool,
reorg_buffer_offset: REORG_BUFFER_OFFSET,
wallet_dir: data_dir,
wallet_name: DEFAULT_WALLET_NAME.into(),
logfile_name: DEFAULT_LOGFILE_NAME.into(),
accept_server_txids: false,
};

Ok(config)
}

/// Same as load_clientconfig but doesn't panic when the server can't be reached
pub fn load_clientconfig_serverless(
pub fn load_clientconfig(
lightwallet_uri: http::Uri,
data_dir: Option<PathBuf>,
chain: ChainType,
Expand Down Expand Up @@ -784,7 +749,7 @@ mod tests {
let temp_path = temp_dir.path().to_path_buf();
// let temp_path_invalid = temp_dir.path().to_path_buf();

let valid_config = crate::config::load_clientconfig_serverless(
let valid_config = crate::config::load_clientconfig(
valid_uri.clone(),
Some(temp_path),
crate::config::ChainType::Mainnet,
Expand Down

0 comments on commit f62b8bf

Please sign in to comment.