Skip to content
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

feat: add bootstrap_peer method to RunningNetwork #2667

Merged
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
13 changes: 13 additions & 0 deletions ant-node/src/spawn/network_spawner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,19 @@ pub struct RunningNetwork {
}

impl RunningNetwork {
/// Returns a bootstrap peer from this network.
pub async fn bootstrap_peer(&self) -> Multiaddr {
self.running_nodes()
.first()
.expect("No nodes running, cannot get bootstrap peer")
.get_listen_addrs_with_peer_id()
.await
.expect("Could not get listen addresses for bootstrap peer")
.last()
.expect("Bootstrap peer has no listen addresses")
.clone()
}

/// Return all running nodes.
pub fn running_nodes(&self) -> &Vec<RunningNode> {
&self.running_nodes
Expand Down
Loading