@@ -19,7 +19,8 @@ impl ClusterConnectionManager {
1919 peer_stream. disseminate_peers ( self . 0 . get_peers ( ) . await ?) . await ?;
2020 peer_stream. may_try_sync ( ccm, & connected_peer_info) . await ?;
2121
22- self . send ( peer_stream. into_add_peer ( self . clone ( ) , connected_peer_info) ?) . await ?;
22+ let ( tx, rx) = tokio:: sync:: oneshot:: channel ( ) ;
23+ self . send ( peer_stream. into_add_peer ( self . clone ( ) , connected_peer_info, tx) ?) . await ?;
2324
2425 Ok ( ( ) )
2526 }
@@ -28,7 +29,7 @@ impl ClusterConnectionManager {
2829 self ,
2930 self_port : u16 ,
3031 connect_to : PeerIdentifier ,
31- tx : Option < tokio:: sync:: oneshot:: Sender < ( ) > > ,
32+ Sender : tokio:: sync:: oneshot:: Sender < ( ) > ,
3233 ) -> anyhow:: Result < ( ) > {
3334 // Base case
3435 let existing_peers = self . get_peers ( ) . await ?;
@@ -44,19 +45,24 @@ impl ClusterConnectionManager {
4445 . await ?
4546 . set_replication_info ( & self )
4647 . await ?
47- . create_peer_cmd ( self . clone ( ) , tx ) ?;
48+ . create_peer_cmd ( self . clone ( ) , Sender ) ?;
4849 self . send ( add_peer_cmd) . await ?;
4950
5051 // Discover additional peers concurrently
5152 // TODO Require investigation. Why does 'list_peer_binding_addrs' have to be called at here?
53+ let mut callbacks = Vec :: new ( ) ;
5254 for peer in peer_list {
5355 println ! ( "Discovering peer: {}" , peer) ;
56+ let ( tx, rx) = tokio:: sync:: oneshot:: channel ( ) ;
5457 Box :: pin (
55- ClusterConnectionManager ( self . 0 . clone ( ) ) . discover_cluster ( self_port, peer, None ) ,
58+ ClusterConnectionManager ( self . 0 . clone ( ) ) . discover_cluster ( self_port, peer, tx ) ,
5659 )
5760 . await ?;
61+ callbacks. push ( rx) ;
62+ }
63+ for callback in callbacks {
64+ let _ = callback. await ;
5865 }
59-
6066 Ok ( ( ) )
6167 }
6268
0 commit comments