Skip to content

Commit a01a791

Browse files
committed
f use scids from removed node
1 parent b579dd5 commit a01a791

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

lightning/src/routing/gossip.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,19 +1529,12 @@ impl<L: Deref> NetworkGraph<L> where L::Target: Logger {
15291529
let mut nodes = self.nodes.write().unwrap();
15301530
let mut channels = self.channels.write().unwrap();
15311531

1532-
let mut scids_to_remove = Vec::new();
1533-
for (scid, info) in channels.iter_mut() {
1534-
if info.node_one == node_id || info.node_two == node_id {
1535-
scids_to_remove.push(*scid);
1536-
}
1537-
}
1538-
nodes.remove(&node_id);
1539-
1540-
if !scids_to_remove.is_empty() {
1541-
// TODO: Use BTreeMap::retain when our MSRV is >= 1.53.
1542-
for scid in scids_to_remove {
1543-
let info = channels.remove(&scid).expect("We just accessed this scid, it should be present");
1544-
Self::remove_channel_in_nodes(&mut nodes, &info, scid);
1532+
if let Some(node) = nodes.remove(&node_id) {
1533+
for scid in node.channels.iter() {
1534+
// TODO: Use BTreeMap::retain when our MSRV is >= 1.53.
1535+
if let Some(info) = channels.remove(scid) {
1536+
Self::remove_channel_in_nodes(&mut nodes, &info, *scid);
1537+
}
15451538
}
15461539
}
15471540
}

0 commit comments

Comments
 (0)