use default nodes if no other node was provided
@@ -143,10 +143,24 @@ impl ClientBuilder {
}
/// Build the Client instance.
- pub fn finish(self) -> Result<Client> {
+ pub fn finish(mut self) -> Result<Client> {
if self.nodes.is_empty() {
+ match self.network_info.network {
+ Network::Testnet => {
+ let default_nodes = vec![
+ "https://api.lb-0.testnet.chrysalis2.com",
+ "https://api.hornet-0.testnet.chrysalis2.com",
+ ];
+ for node in default_nodes.iter() {
+ let url = Url::parse(node).map_err(|_| Error::UrlError)?;
+ self.nodes.insert(url);
+ }
+ }
+ Network::Mainnet => {
return Err(Error::MissingParameter(String::from("Iota node")));
}
+ }
+ }
let network_info = Arc::new(RwLock::new(self.network_info));
let nodes = self.nodes;
