@@ -320,28 +320,24 @@ where C::Target: chain::Access, L::Target: Logger
320320
321321 fn get_next_channel_announcement ( & self , starting_point : u64 ) -> Option < ( ChannelAnnouncement , Option < ChannelUpdate > , Option < ChannelUpdate > ) > {
322322 let channels = self . network_graph . channels . read ( ) . unwrap ( ) ;
323- let mut iter = channels. range ( starting_point..) ;
324- loop {
325- if let Some ( ( _, ref chan) ) = iter. next ( ) {
326- if chan. announcement_message . is_some ( ) {
327- let chan_announcement = chan. announcement_message . clone ( ) . unwrap ( ) ;
328- let mut one_to_two_announcement: Option < msgs:: ChannelUpdate > = None ;
329- let mut two_to_one_announcement: Option < msgs:: ChannelUpdate > = None ;
330- if let Some ( one_to_two) = chan. one_to_two . as_ref ( ) {
331- one_to_two_announcement = one_to_two. last_update_message . clone ( ) ;
332- }
333- if let Some ( two_to_one) = chan. two_to_one . as_ref ( ) {
334- two_to_one_announcement = two_to_one. last_update_message . clone ( ) ;
335- }
336- return Some ( ( chan_announcement, one_to_two_announcement, two_to_one_announcement) ) ;
337- } else {
338- // TODO: We may end up sending un-announced channel_updates if we are sending
339- // initial sync data while receiving announce/updates for this channel.
323+ for ( _, ref chan) in channels. range ( starting_point..) {
324+ if chan. announcement_message . is_some ( ) {
325+ let chan_announcement = chan. announcement_message . clone ( ) . unwrap ( ) ;
326+ let mut one_to_two_announcement: Option < msgs:: ChannelUpdate > = None ;
327+ let mut two_to_one_announcement: Option < msgs:: ChannelUpdate > = None ;
328+ if let Some ( one_to_two) = chan. one_to_two . as_ref ( ) {
329+ one_to_two_announcement = one_to_two. last_update_message . clone ( ) ;
340330 }
331+ if let Some ( two_to_one) = chan. two_to_one . as_ref ( ) {
332+ two_to_one_announcement = two_to_one. last_update_message . clone ( ) ;
333+ }
334+ return Some ( ( chan_announcement, one_to_two_announcement, two_to_one_announcement) ) ;
341335 } else {
342- return None ;
336+ // TODO: We may end up sending un-announced channel_updates if we are sending
337+ // initial sync data while receiving announce/updates for this channel.
343338 }
344339 }
340+ None
345341 }
346342
347343 fn get_next_node_announcement ( & self , starting_point : Option < & PublicKey > ) -> Option < NodeAnnouncement > {
@@ -353,17 +349,14 @@ where C::Target: chain::Access, L::Target: Logger
353349 } else {
354350 nodes. range :: < NodeId , _ > ( ..)
355351 } ;
356- loop {
357- if let Some ( ( _, ref node) ) = iter. next ( ) {
358- if let Some ( node_info) = node. announcement_info . as_ref ( ) {
359- if let Some ( msg) = node_info. announcement_message . clone ( ) {
360- return Some ( msg) ;
361- }
352+ for ( _, ref node) in iter {
353+ if let Some ( node_info) = node. announcement_info . as_ref ( ) {
354+ if let Some ( msg) = node_info. announcement_message . clone ( ) {
355+ return Some ( msg) ;
362356 }
363- } else {
364- return None ;
365357 }
366358 }
359+ None
367360 }
368361
369362 /// Initiates a stateless sync of routing gossip information with a peer
0 commit comments