@@ -31,8 +31,8 @@ use zenoh_protocol::{
31
31
use zenoh_sync:: get_mut_unchecked;
32
32
33
33
use super :: {
34
- face_hat, face_hat_mut, get_peer, get_routes_entries , hat, hat_mut, network:: Network , res_hat,
35
- res_hat_mut , HatCode , HatContext , HatFace , HatTables ,
34
+ face_hat, face_hat_mut, get_peer, hat, hat_mut, network:: Network , res_hat, res_hat_mut ,
35
+ HatCode , HatContext , HatFace , HatTables ,
36
36
} ;
37
37
#[ cfg( feature = "unstable" ) ]
38
38
use crate :: key_expr:: KeyExpr ;
@@ -44,8 +44,7 @@ use crate::net::routing::{
44
44
resource:: { NodeId , Resource , SessionContext } ,
45
45
tables:: { Route , RoutingExpr , Tables } ,
46
46
} ,
47
- hat:: { CurrentFutureTrait , HatPubSubTrait , SendDeclare , Sources } ,
48
- router:: RoutesIndexes ,
47
+ hat:: { CurrentFutureTrait , DataRoutes , HatPubSubTrait , SendDeclare , Sources } ,
49
48
RoutingContext ,
50
49
} ;
51
50
@@ -986,8 +985,36 @@ impl HatPubSubTrait for HatCode {
986
985
Arc :: new ( route)
987
986
}
988
987
989
- fn get_data_routes_entries ( & self , tables : & Tables ) -> RoutesIndexes {
990
- get_routes_entries ( tables)
988
+ fn compute_data_routes (
989
+ & self ,
990
+ tables : & Tables ,
991
+ routes : & mut DataRoutes ,
992
+ expr : & mut RoutingExpr ,
993
+ ) {
994
+ let indexes = hat ! ( tables)
995
+ . linkstatepeers_net
996
+ . as_ref ( )
997
+ . unwrap ( )
998
+ . graph
999
+ . node_indices ( )
1000
+ . map ( |i| i. index ( ) as NodeId )
1001
+ . collect :: < Vec < NodeId > > ( ) ;
1002
+ let max_idx = indexes. iter ( ) . max ( ) . unwrap ( ) ;
1003
+ routes
1004
+ . routers
1005
+ . resize_with ( ( * max_idx as usize ) + 1 , || Arc :: new ( HashMap :: new ( ) ) ) ;
1006
+ routes
1007
+ . peers
1008
+ . resize_with ( ( * max_idx as usize ) + 1 , || Arc :: new ( HashMap :: new ( ) ) ) ;
1009
+ for idx in indexes {
1010
+ let route = self . compute_data_route ( tables, expr, idx, WhatAmI :: Peer ) ;
1011
+ routes. routers [ idx as usize ] = route. clone ( ) ;
1012
+ routes. peers [ idx as usize ] = route;
1013
+ }
1014
+
1015
+ routes. clients . resize_with ( 1 , || {
1016
+ self . compute_data_route ( tables, expr, 0 , WhatAmI :: Client )
1017
+ } ) ;
991
1018
}
992
1019
993
1020
#[ zenoh_macros:: unstable]
0 commit comments