Skip to content

Commit

Permalink
Merge pull request #2667 from mickvandijke/feat-add-bootstrap-peer-fn…
Browse files Browse the repository at this point in the history
…-to-running-network

feat: add `bootstrap_peer` method to `RunningNetwork`
  • Loading branch information
mickvandijke authored Jan 24, 2025
2 parents b846ea1 + 6d9044a commit 84ab480
Showing 1 changed file with 13 additions and 0 deletions.
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

0 comments on commit 84ab480

Please sign in to comment.