Fix handling failed route lookups
[dnsseed-rust] / src / bgp_client.rs
index cb33305d4e17bde8b2d318fa438fb89775ddf2f4..a890dad9cd72b227c5948461eefab5d2979899c8 100644 (file)
@@ -182,7 +182,7 @@ impl BGPClient {
                                .then(path_b.med.cmp(&path_a.med))
                });
                // TODO: Find last common ASN among all paths
-               *path_vecs[0].path.last().unwrap_or(&0)
+               *path_vecs.first().map(|route| route.path.last().unwrap_or(&0)).unwrap_or(&0)
        }
 
        pub fn disconnect(&self) {