Skip to content

Commit 33737bf

Browse files
authored
Merge pull request #1097 from TheBlueMatt/2021-09-clonable-netgraph
Make `NetworkGraph` Clone-able again
2 parents 367a2cc + 6c569d8 commit 33737bf

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lightning/src/routing/network_graph.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,18 @@ pub struct NetworkGraph {
5858
nodes: RwLock<BTreeMap<PublicKey, NodeInfo>>,
5959
}
6060

61+
impl Clone for NetworkGraph {
62+
fn clone(&self) -> Self {
63+
let channels = self.channels.read().unwrap();
64+
let nodes = self.nodes.read().unwrap();
65+
Self {
66+
genesis_hash: self.genesis_hash.clone(),
67+
channels: RwLock::new(channels.clone()),
68+
nodes: RwLock::new(nodes.clone()),
69+
}
70+
}
71+
}
72+
6173
/// A read-only view of [`NetworkGraph`].
6274
pub struct ReadOnlyNetworkGraph<'a> {
6375
channels: RwLockReadGuard<'a, BTreeMap<u64, ChannelInfo>>,

0 commit comments

Comments
 (0)