Skip to content

Commit 586dfea

Browse files
committed
Reduce RwLock usage in public interface of NetworkGraph
This isn't a big difference in the API, but it avoids needing to wrap a given NetworkGraph in a RwLock before passing it, which makes it much easier to generate C bindings for.
1 parent 72de627 commit 586dfea

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lightning/src/ln/functional_test_utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use rand::{thread_rng,Rng};
3333

3434
use std::cell::RefCell;
3535
use std::rc::Rc;
36-
use std::sync::{Mutex, RwLock};
36+
use std::sync::Mutex;
3737
use std::mem;
3838
use std::collections::HashMap;
3939

@@ -105,7 +105,7 @@ impl<'a, 'b, 'c> Drop for Node<'a, 'b, 'c> {
105105
let network_graph_deser = <NetworkGraph>::read(&mut ::std::io::Cursor::new(&w.0)).unwrap();
106106
assert!(network_graph_deser == *self.net_graph_msg_handler.network_graph.read().unwrap());
107107
let net_graph_msg_handler = NetGraphMsgHandler::from_net_graph(
108-
self.chain_monitor, self.logger, RwLock::new(network_graph_deser)
108+
self.chain_monitor, self.logger, network_graph_deser
109109
);
110110
let mut chan_progress = 0;
111111
loop {

lightning/src/routing/network_graph.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ impl<C: Deref, L: Deref> NetGraphMsgHandler<C, L> where C::Target: ChainWatchInt
5959

6060
/// Creates a new tracker of the actual state of the network of channels and nodes,
6161
/// assuming an existing Network Graph.
62-
pub fn from_net_graph(chain_monitor: C, logger: L, network_graph: RwLock<NetworkGraph>) -> Self {
62+
pub fn from_net_graph(chain_monitor: C, logger: L, network_graph: NetworkGraph) -> Self {
6363
NetGraphMsgHandler {
6464
secp_ctx: Secp256k1::verification_only(),
65-
network_graph,
65+
network_graph: RwLock::new(network_graph),
6666
full_syncs_requested: AtomicUsize::new(0),
6767
chain_monitor,
6868
logger,

0 commit comments

Comments
 (0)