Skip to content

Commit c33a444

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 9e58009 commit c33a444

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
@@ -31,7 +31,7 @@ use bitcoin::secp256k1::key::PublicKey;
3131

3232
use std::cell::RefCell;
3333
use std::rc::Rc;
34-
use std::sync::{Mutex, RwLock};
34+
use std::sync::Mutex;
3535
use std::mem;
3636
use std::collections::HashMap;
3737

@@ -103,7 +103,7 @@ impl<'a, 'b, 'c> Drop for Node<'a, 'b, 'c> {
103103
let network_graph_deser = <NetworkGraph>::read(&mut ::std::io::Cursor::new(&w.0)).unwrap();
104104
assert!(network_graph_deser == *self.net_graph_msg_handler.network_graph.read().unwrap());
105105
let net_graph_msg_handler = NetGraphMsgHandler::from_net_graph(
106-
self.chain_monitor, self.logger, RwLock::new(network_graph_deser)
106+
self.chain_monitor, self.logger, network_graph_deser
107107
);
108108
let mut chan_progress = 0;
109109
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)