Skip to content

Commit f08bdb5

Browse files
committed
f map/collect
1 parent 49a3a8e commit f08bdb5

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,21 +1796,20 @@ where
17961796

17971797
/// Gets the list of channels we have with a given counterparty, in random order.
17981798
pub fn list_channels_with_counterparty(&self, counterparty_node_id: &PublicKey) -> Vec<ChannelDetails> {
1799-
let mut res = Vec::with_capacity(self.short_to_chan_info.read().unwrap().len());
18001799
let best_block_height = self.best_block.read().unwrap().height();
18011800
let per_peer_state = self.per_peer_state.read().unwrap();
18021801

18031802
if let Some(peer_state_mutex) = per_peer_state.get(counterparty_node_id) {
18041803
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
18051804
let peer_state = &mut *peer_state_lock;
1806-
for (_channel_id, channel) in peer_state.channel_by_id.iter() {
1807-
let details = ChannelDetails::from_channel(channel, best_block_height,
1808-
peer_state.latest_features.clone());
1809-
res.push(details);
1810-
}
1811-
}
1812-
1813-
res
1805+
let features = &peer_state.latest_features;
1806+
return peer_state.channel_by_id
1807+
.iter()
1808+
.map(|(_, channel)|
1809+
ChannelDetails::from_channel(channel, best_block_height, features.clone()))
1810+
.collect();
1811+
}
1812+
vec![]
18141813
}
18151814

18161815
/// Returns in an undefined order recent payments that -- if not fulfilled -- have yet to find a

0 commit comments

Comments
 (0)