Clean up iteration in handle_query_channel_range
authorbmancini55 <bmancini@gmail.com>
Tue, 9 Mar 2021 21:30:52 +0000 (16:30 -0500)
committerbmancini55 <bmancini@gmail.com>
Tue, 9 Mar 2021 21:30:52 +0000 (16:30 -0500)
Refactor to use an enumerator in NetGraphMsgHandler::handle_query_channel_range

lightning/src/routing/network_graph.rs

index b8655fb0abd3d59bed177456d572dc2529733b1d..44ee21ab8270b73c02e516112d75dd6126f0c930 100644 (file)
@@ -369,9 +369,8 @@ impl<C: Deref + Sync + Send, L: Deref + Sync + Send> RoutingMessageHandler for N
                drop(network_graph);
 
                let mut pending_events = self.pending_events.lock().unwrap();
-               let mut batch_index = 0;
                let batch_count = batches.len();
-               for batch in batches.into_iter() {
+               for (batch_index, batch) in batches.into_iter().enumerate() {
                        // Per spec, the initial first_blocknum needs to be <= the query's first_blocknum.
                        // Use the query's values since we don't use pre-processed reply ranges.
                        let first_blocknum = if batch_index == 0 {
@@ -409,8 +408,6 @@ impl<C: Deref + Sync + Send, L: Deref + Sync + Send> RoutingMessageHandler for N
                                        short_channel_ids: batch,
                                }
                        });
-
-                       batch_index += 1;
                }
 
                Ok(())