Skip to content

adds checks before attempting to connect broadcast providers #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,19 @@ impl BuilderConfig {
pub async fn connect_additional_broadcast(
&self,
) -> Result<Vec<RootProvider<BoxTransport>>, ConfigError> {
let mut providers = Vec::with_capacity(self.tx_broadcast_urls.len());
for url in self.tx_broadcast_urls.iter() {
let provider =
ProviderBuilder::new().on_builtin(url).await.map_err(Into::<ConfigError>::into)?;
providers.push(provider);
if !self.tx_broadcast_urls.is_empty() && self.tx_broadcast_urls[0] != "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we just do this when we actually populate self.tx_broadcast_urls?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that works too. I was thinking about the case where we wanted to do additional setup or validation with the URLs but this works.

let mut providers = Vec::with_capacity(self.tx_broadcast_urls.len());
for url in self.tx_broadcast_urls.iter() {
let provider = ProviderBuilder::new()
.on_builtin(url)
.await
.map_err(Into::<ConfigError>::into)?;
providers.push(provider);
}
Ok(providers)
} else {
Ok(vec![])
}
Ok(providers)
}

pub fn connect_zenith(&self, provider: Provider) -> ZenithInstance {
Expand Down
Loading