File tree 1 file changed +10
-1
lines changed
1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -836,8 +836,17 @@ impl Endpoint {
836
836
/// The returned [`NodeAddr`] will have the current [`RelayUrl`] and direct addresses
837
837
/// as they would be returned by [`Endpoint::home_relay`] and
838
838
/// [`Endpoint::direct_addresses`].
839
+ ///
840
+ /// This function is async because it waits for either the node's direct addresses
841
+ /// or the node's home relay are initialized.
839
842
pub async fn node_addr ( & self ) -> Result < NodeAddr > {
840
- let addrs = self . direct_addresses ( ) . initialized ( ) . await ?;
843
+ // Wait for either the home relay or the direct addresses to be ready.
844
+ n0_future:: future:: race (
845
+ async { self . direct_addresses ( ) . initialized ( ) . await . map ( |_| ( ) ) } ,
846
+ async { self . home_relay ( ) . initialized ( ) . await . map ( |_| ( ) ) } ,
847
+ )
848
+ . await ?;
849
+ let addrs = self . direct_addresses ( ) . get ( ) ?. unwrap_or_default ( ) ;
841
850
let relay = self . home_relay ( ) . get ( ) ?;
842
851
Ok ( NodeAddr :: from_parts (
843
852
self . node_id ( ) ,
You can’t perform that action at this time.
0 commit comments