@@ -109,7 +109,10 @@ impl Intern {
109109 vec ! [ ModuleMessage :: ConnectedIDsReply ( self . core. active_nodes( ) )
110110 . wrapper_network( from) ]
111111 }
112- ModuleMessage :: ConnectedIDsReply ( nodes) => self . add_nodes ( nodes) ,
112+ ModuleMessage :: ConnectedIDsReply ( nodes) => {
113+ self . core . add_nodes ( nodes) ;
114+ vec ! [ ]
115+ }
113116 } ,
114117 None => vec ! [ ] ,
115118 } ;
@@ -153,40 +156,40 @@ impl Intern {
153156 }
154157
155158 fn msg_network ( & mut self , msg : RouterOut ) -> Vec < InternOut > {
159+ // log::info!("msg_network({msg})");
156160 match msg {
157161 RouterOut :: NodeInfoAvailable ( node_infos) => self . add_node_infos ( node_infos) ,
158162 RouterOut :: NodeIDsConnected ( connected) => {
159163 self . connected = connected. 0 . clone ( ) ;
160- self . add_nodes ( connected. 0 )
164+ self . core . add_nodes ( connected. 0 ) ;
161165 }
162166 RouterOut :: NetworkWrapperFromNetwork ( from, network_wrapper) => {
163- self . process_node_message ( from, network_wrapper)
167+ return self . process_node_message ( from, network_wrapper)
168+ }
169+ RouterOut :: SystemConfig ( conf) => {
170+ return conf
171+ . system_realm
172+ . map ( |rid| vec ! [ InternOut :: DHTRouter ( DHTRouterOut :: SystemRealm ( rid) ) ] )
173+ . unwrap_or ( vec ! [ ] )
164174 }
165- RouterOut :: SystemConfig ( conf) => conf
166- . system_realm
167- . map ( |rid| vec ! [ InternOut :: DHTRouter ( DHTRouterOut :: SystemRealm ( rid) ) ] )
168- . unwrap_or ( vec ! [ ] ) ,
169175 RouterOut :: Disconnected ( id) => {
170- self . core . node_disconnected ( id) ;
171- vec ! [ ]
176+ self . core . node_disconnected ( & id) ;
177+ }
178+ RouterOut :: Connected ( id) => {
179+ self . core . add_node ( id) ;
172180 }
173- _ => vec ! [ ] ,
181+ _ => { }
174182 }
183+ vec ! [ ]
175184 }
176185
177186 // Stores the new node list, excluding the ID of this node.
178- fn add_node_infos ( & mut self , infos : Vec < NodeInfo > ) -> Vec < InternOut > {
187+ fn add_node_infos ( & mut self , infos : Vec < NodeInfo > ) {
179188 for info in & infos {
180189 self . infos . insert ( info. get_id ( ) , info. clone ( ) ) ;
181190 }
182- self . add_nodes ( infos. iter ( ) . map ( |i| i. get_id ( ) ) . collect ( ) )
183- }
184-
185- fn add_nodes ( & mut self , nodes : Vec < NodeID > ) -> Vec < InternOut > {
186- self . core . add_nodes ( nodes) ;
187- vec ! [ InternOut :: DHTRouter ( DHTRouterOut :: NodeList (
188- self . core. active_nodes( ) ,
189- ) ) ]
191+ self . core
192+ . add_nodes ( infos. iter ( ) . map ( |i| i. get_id ( ) ) . collect ( ) ) ;
190193 }
191194
192195 // One second passes - and return messages for nodes to ping.
@@ -407,7 +410,7 @@ mod tests {
407410 InternIn :: Tick ,
408411 ] )
409412 . await ;
410- assert_eq ! ( 5 , out. len( ) ) ;
413+ assert_eq ! ( 4 , out. len( ) ) ;
411414
412415 Ok ( ( ) )
413416 }
0 commit comments