Consider many first-hop paths to the same counterparty in routing
[rust-lightning] / lightning / src / routing / network_graph.rs
index 29bbc580a40384de0dda1fd9d1b29bfcff2620d6..bdb305e7870a2b9a30e9236c34b516dc2328c873 100644 (file)
@@ -58,6 +58,18 @@ pub struct NetworkGraph {
        nodes: RwLock<BTreeMap<PublicKey, NodeInfo>>,
 }
 
+impl Clone for NetworkGraph {
+       fn clone(&self) -> Self {
+               let channels = self.channels.read().unwrap();
+               let nodes = self.nodes.read().unwrap();
+               Self {
+                       genesis_hash: self.genesis_hash.clone(),
+                       channels: RwLock::new(channels.clone()),
+                       nodes: RwLock::new(nodes.clone()),
+               }
+       }
+}
+
 /// A read-only view of [`NetworkGraph`].
 pub struct ReadOnlyNetworkGraph<'a> {
        channels: RwLockReadGuard<'a, BTreeMap<u64, ChannelInfo>>,