Rename NetGraphMsgHandler to P2PGossipSync
authorJeffrey Czyz <jkczyz@gmail.com>
Wed, 1 Jun 2022 17:28:34 +0000 (10:28 -0700)
committerJeffrey Czyz <jkczyz@gmail.com>
Thu, 2 Jun 2022 22:15:30 +0000 (15:15 -0700)
NetGraphMsgHandler implements RoutingMessageHandler to handle gossip
messages defined in BOLT 7 and maintains a view of the network by
updating NetworkGraph. Rename it to P2PGossipSync, which better
describes its purpose, and to contrast with RapidGossipSync.

12 files changed:
ARCH.md
fuzz/src/full_stack.rs
lightning-background-processor/src/lib.rs
lightning/src/ln/chanmon_update_fail_tests.rs
lightning/src/ln/functional_test_utils.rs
lightning/src/ln/functional_tests.rs
lightning/src/ln/mod.rs
lightning/src/ln/peer_handler.rs
lightning/src/ln/priv_short_conf_tests.rs
lightning/src/routing/network_graph.rs
lightning/src/routing/router.rs
lightning/src/util/events.rs

diff --git a/ARCH.md b/ARCH.md
index e48568bdee476ec2ffa934385592fc6450f16156..9efccd9c9ddcec9d9812e0d0eb420975b3a0e98c 100644 (file)
--- a/ARCH.md
+++ b/ARCH.md
@@ -11,10 +11,10 @@ receive `ChannelMonitorUpdate`s from `ChannelManager` and persist them to disk b
 channel steps forward.
 
 There are two additional important structures that you may use either on the same device
 channel steps forward.
 
 There are two additional important structures that you may use either on the same device
-as the `ChannelManager` or on a separate one. `NetGraphMsgHandler` handles receiving channel
+as the `ChannelManager` or on a separate one. `P2PGossipSync` handles receiving channel
 and node announcements, which are then used to calculate routes by `find_route` for sending
 payments. `PeerManager` handles the authenticated and encrypted communication protocol,
 and node announcements, which are then used to calculate routes by `find_route` for sending
 payments. `PeerManager` handles the authenticated and encrypted communication protocol,
-monitoring for liveness of peers, routing messages to `ChannelManager` and `NetGraphMsgHandler`
+monitoring for liveness of peers, routing messages to `ChannelManager` and `P2PGossipSync`
 instances directly, and receiving messages from them via the `EventsProvider` interface.
 
 These structs communicate with each other using a public API, so that you can easily add
 instances directly, and receiving messages from them via the `EventsProvider` interface.
 
 These structs communicate with each other using a public API, so that you can easily add
@@ -56,7 +56,7 @@ At a high level, some of the common interfaces fit together as follows:
  |                    -----------------          \   /  ----------------
  |                            ^                   \ /          |
 (as RoutingMessageHandler)    |                    v           v
  |                    -----------------          \   /  ----------------
  |                            ^                   \ /          |
 (as RoutingMessageHandler)    |                    v           v
-  \                   ----------------------   ---------   -----------------
-   -----------------> | NetGraphMsgHandler |   | Event |   | chain::Filter |
-                      ----------------------   ---------   -----------------
+  \                   -----------------        ---------   -----------------
+   -----------------> | P2PGossipSync |        | Event |   | chain::Filter |
+                      -----------------        ---------   -----------------
 ```
 ```
index 00b123b84dd1942da7f20d1be5fdf10f2cd8a1fd..1c9c590f8bbf7dde61692ed8548bb53e4eb7b259 100644 (file)
@@ -37,7 +37,7 @@ use lightning::ln::channelmanager::{ChainParameters, ChannelManager};
 use lightning::ln::peer_handler::{MessageHandler,PeerManager,SocketDescriptor,IgnoringMessageHandler};
 use lightning::ln::msgs::DecodeError;
 use lightning::ln::script::ShutdownScript;
 use lightning::ln::peer_handler::{MessageHandler,PeerManager,SocketDescriptor,IgnoringMessageHandler};
 use lightning::ln::msgs::DecodeError;
 use lightning::ln::script::ShutdownScript;
-use lightning::routing::network_graph::{NetGraphMsgHandler, NetworkGraph};
+use lightning::routing::network_graph::{P2PGossipSync, NetworkGraph};
 use lightning::routing::router::{find_route, PaymentParameters, RouteParameters};
 use lightning::routing::scoring::FixedPenaltyScorer;
 use lightning::util::config::UserConfig;
 use lightning::routing::router::{find_route, PaymentParameters, RouteParameters};
 use lightning::routing::scoring::FixedPenaltyScorer;
 use lightning::util::config::UserConfig;
@@ -163,7 +163,7 @@ type ChannelMan = ChannelManager<
        EnforcingSigner,
        Arc<chainmonitor::ChainMonitor<EnforcingSigner, Arc<dyn chain::Filter>, Arc<TestBroadcaster>, Arc<FuzzEstimator>, Arc<dyn Logger>, Arc<TestPersister>>>,
        Arc<TestBroadcaster>, Arc<KeyProvider>, Arc<FuzzEstimator>, Arc<dyn Logger>>;
        EnforcingSigner,
        Arc<chainmonitor::ChainMonitor<EnforcingSigner, Arc<dyn chain::Filter>, Arc<TestBroadcaster>, Arc<FuzzEstimator>, Arc<dyn Logger>, Arc<TestPersister>>>,
        Arc<TestBroadcaster>, Arc<KeyProvider>, Arc<FuzzEstimator>, Arc<dyn Logger>>;
-type PeerMan<'a> = PeerManager<Peer<'a>, Arc<ChannelMan>, Arc<NetGraphMsgHandler<Arc<NetworkGraph>, Arc<dyn chain::Access>, Arc<dyn Logger>>>, Arc<dyn Logger>, IgnoringMessageHandler>;
+type PeerMan<'a> = PeerManager<Peer<'a>, Arc<ChannelMan>, Arc<P2PGossipSync<Arc<NetworkGraph>, Arc<dyn chain::Access>, Arc<dyn Logger>>>, Arc<dyn Logger>, IgnoringMessageHandler>;
 
 struct MoneyLossDetector<'a> {
        manager: Arc<ChannelMan>,
 
 struct MoneyLossDetector<'a> {
        manager: Arc<ChannelMan>,
@@ -396,13 +396,13 @@ pub fn do_test(data: &[u8], logger: &Arc<dyn Logger>) {
        keys_manager.counter.fetch_sub(1, Ordering::AcqRel);
        let our_id = PublicKey::from_secret_key(&Secp256k1::signing_only(), &keys_manager.get_node_secret(Recipient::Node).unwrap());
        let network_graph = Arc::new(NetworkGraph::new(genesis_block(network).block_hash()));
        keys_manager.counter.fetch_sub(1, Ordering::AcqRel);
        let our_id = PublicKey::from_secret_key(&Secp256k1::signing_only(), &keys_manager.get_node_secret(Recipient::Node).unwrap());
        let network_graph = Arc::new(NetworkGraph::new(genesis_block(network).block_hash()));
-       let net_graph_msg_handler = Arc::new(NetGraphMsgHandler::new(Arc::clone(&network_graph), None, Arc::clone(&logger)));
+       let gossip_sync = Arc::new(P2PGossipSync::new(Arc::clone(&network_graph), None, Arc::clone(&logger)));
        let scorer = FixedPenaltyScorer::with_penalty(0);
 
        let peers = RefCell::new([false; 256]);
        let mut loss_detector = MoneyLossDetector::new(&peers, channelmanager.clone(), monitor.clone(), PeerManager::new(MessageHandler {
                chan_handler: channelmanager.clone(),
        let scorer = FixedPenaltyScorer::with_penalty(0);
 
        let peers = RefCell::new([false; 256]);
        let mut loss_detector = MoneyLossDetector::new(&peers, channelmanager.clone(), monitor.clone(), PeerManager::new(MessageHandler {
                chan_handler: channelmanager.clone(),
-               route_handler: net_graph_msg_handler.clone(),
+               route_handler: gossip_sync.clone(),
        }, our_network_key, &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0], Arc::clone(&logger), IgnoringMessageHandler{}));
 
        let mut should_forward = false;
        }, our_network_key, &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0], Arc::clone(&logger), IgnoringMessageHandler{}));
 
        let mut should_forward = false;
index 0fab3e61a4af982fb49f14d89865133af29dad45..9783f9e7ebc2a5d31b3f4d76220eea104a9a7125 100644 (file)
@@ -18,7 +18,7 @@ use lightning::chain::keysinterface::{Sign, KeysInterface};
 use lightning::ln::channelmanager::ChannelManager;
 use lightning::ln::msgs::{ChannelMessageHandler, RoutingMessageHandler};
 use lightning::ln::peer_handler::{CustomMessageHandler, PeerManager, SocketDescriptor};
 use lightning::ln::channelmanager::ChannelManager;
 use lightning::ln::msgs::{ChannelMessageHandler, RoutingMessageHandler};
 use lightning::ln::peer_handler::{CustomMessageHandler, PeerManager, SocketDescriptor};
-use lightning::routing::network_graph::{NetworkGraph, NetGraphMsgHandler};
+use lightning::routing::network_graph::{NetworkGraph, P2PGossipSync};
 use lightning::routing::scoring::WriteableScore;
 use lightning::util::events::{Event, EventHandler, EventsProvider};
 use lightning::util::logger::Logger;
 use lightning::routing::scoring::WriteableScore;
 use lightning::util::events::{Event, EventHandler, EventsProvider};
 use lightning::util::logger::Logger;
@@ -40,7 +40,7 @@ use std::ops::Deref;
 ///   [`ChannelManager`] persistence should be done in the background.
 /// * Calling [`ChannelManager::timer_tick_occurred`] and [`PeerManager::timer_tick_occurred`]
 ///   at the appropriate intervals.
 ///   [`ChannelManager`] persistence should be done in the background.
 /// * Calling [`ChannelManager::timer_tick_occurred`] and [`PeerManager::timer_tick_occurred`]
 ///   at the appropriate intervals.
-/// * Calling [`NetworkGraph::remove_stale_channels`] (if a [`NetGraphMsgHandler`] is provided to
+/// * Calling [`NetworkGraph::remove_stale_channels`] (if a [`P2PGossipSync`] is provided to
 ///   [`BackgroundProcessor::start`]).
 ///
 /// It will also call [`PeerManager::process_events`] periodically though this shouldn't be relied
 ///   [`BackgroundProcessor::start`]).
 ///
 /// It will also call [`PeerManager::process_events`] periodically though this shouldn't be relied
@@ -93,26 +93,26 @@ const FIRST_NETWORK_PRUNE_TIMER: u64 = 1;
 /// Decorates an [`EventHandler`] with common functionality provided by standard [`EventHandler`]s.
 struct DecoratingEventHandler<
        E: EventHandler,
 /// Decorates an [`EventHandler`] with common functionality provided by standard [`EventHandler`]s.
 struct DecoratingEventHandler<
        E: EventHandler,
-       N: Deref<Target = NetGraphMsgHandler<G, A, L>>,
+       P: Deref<Target = P2PGossipSync<G, A, L>>,
        G: Deref<Target = NetworkGraph>,
        A: Deref,
        L: Deref,
 >
 where A::Target: chain::Access, L::Target: Logger {
        event_handler: E,
        G: Deref<Target = NetworkGraph>,
        A: Deref,
        L: Deref,
 >
 where A::Target: chain::Access, L::Target: Logger {
        event_handler: E,
-       net_graph_msg_handler: Option<N>,
+       p2p_gossip_sync: Option<P>,
 }
 
 impl<
        E: EventHandler,
 }
 
 impl<
        E: EventHandler,
-       N: Deref<Target = NetGraphMsgHandler<G, A, L>>,
+       P: Deref<Target = P2PGossipSync<G, A, L>>,
        G: Deref<Target = NetworkGraph>,
        A: Deref,
        L: Deref,
        G: Deref<Target = NetworkGraph>,
        A: Deref,
        L: Deref,
-> EventHandler for DecoratingEventHandler<E, N, G, A, L>
+> EventHandler for DecoratingEventHandler<E, P, G, A, L>
 where A::Target: chain::Access, L::Target: Logger {
        fn handle_event(&self, event: &Event) {
 where A::Target: chain::Access, L::Target: Logger {
        fn handle_event(&self, event: &Event) {
-               if let Some(event_handler) = &self.net_graph_msg_handler {
+               if let Some(event_handler) = &self.p2p_gossip_sync {
                        event_handler.handle_event(event);
                }
                self.event_handler.handle_event(event);
                        event_handler.handle_event(event);
                }
                self.event_handler.handle_event(event);
@@ -147,7 +147,7 @@ impl BackgroundProcessor {
        /// `event_handler` is responsible for handling events that users should be notified of (e.g.,
        /// payment failed). [`BackgroundProcessor`] may decorate the given [`EventHandler`] with common
        /// functionality implemented by other handlers.
        /// `event_handler` is responsible for handling events that users should be notified of (e.g.,
        /// payment failed). [`BackgroundProcessor`] may decorate the given [`EventHandler`] with common
        /// functionality implemented by other handlers.
-       /// * [`NetGraphMsgHandler`] if given will update the [`NetworkGraph`] based on payment failures.
+       /// * [`P2PGossipSync`] if given will update the [`NetworkGraph`] based on payment failures.
        ///
        /// # Rapid Gossip Sync
        ///
        ///
        /// # Rapid Gossip Sync
        ///
@@ -183,7 +183,7 @@ impl BackgroundProcessor {
                PS: 'static + Deref + Send,
                M: 'static + Deref<Target = ChainMonitor<Signer, CF, T, F, L, P>> + Send + Sync,
                CM: 'static + Deref<Target = ChannelManager<Signer, CW, T, K, F, L>> + Send + Sync,
                PS: 'static + Deref + Send,
                M: 'static + Deref<Target = ChainMonitor<Signer, CF, T, F, L, P>> + Send + Sync,
                CM: 'static + Deref<Target = ChannelManager<Signer, CW, T, K, F, L>> + Send + Sync,
-               NG: 'static + Deref<Target = NetGraphMsgHandler<G, CA, L>> + Send + Sync,
+               PGS: 'static + Deref<Target = P2PGossipSync<G, CA, L>> + Send + Sync,
                UMH: 'static + Deref + Send + Sync,
                PM: 'static + Deref<Target = PeerManager<Descriptor, CMH, RMH, L, UMH>> + Send + Sync,
                S: 'static + Deref<Target = SC> + Send + Sync,
                UMH: 'static + Deref + Send + Sync,
                PM: 'static + Deref<Target = PeerManager<Descriptor, CMH, RMH, L, UMH>> + Send + Sync,
                S: 'static + Deref<Target = SC> + Send + Sync,
@@ -191,7 +191,7 @@ impl BackgroundProcessor {
                RGS: 'static + Deref<Target = RapidGossipSync<G>> + Send
        >(
                persister: PS, event_handler: EH, chain_monitor: M, channel_manager: CM,
                RGS: 'static + Deref<Target = RapidGossipSync<G>> + Send
        >(
                persister: PS, event_handler: EH, chain_monitor: M, channel_manager: CM,
-               net_graph_msg_handler: Option<NG>, peer_manager: PM, logger: L, scorer: Option<S>,
+               p2p_gossip_sync: Option<PGS>, peer_manager: PM, logger: L, scorer: Option<S>,
                rapid_gossip_sync: Option<RGS>
        ) -> Self
        where
                rapid_gossip_sync: Option<RGS>
        ) -> Self
        where
@@ -211,7 +211,7 @@ impl BackgroundProcessor {
                let stop_thread = Arc::new(AtomicBool::new(false));
                let stop_thread_clone = stop_thread.clone();
                let handle = thread::spawn(move || -> Result<(), std::io::Error> {
                let stop_thread = Arc::new(AtomicBool::new(false));
                let stop_thread_clone = stop_thread.clone();
                let handle = thread::spawn(move || -> Result<(), std::io::Error> {
-                       let event_handler = DecoratingEventHandler { event_handler, net_graph_msg_handler: net_graph_msg_handler.as_ref().map(|t| t.deref()) };
+                       let event_handler = DecoratingEventHandler { event_handler, p2p_gossip_sync: p2p_gossip_sync.as_ref().map(|t| t.deref()) };
 
                        log_trace!(logger, "Calling ChannelManager's timer_tick_occurred on startup");
                        channel_manager.timer_tick_occurred();
 
                        log_trace!(logger, "Calling ChannelManager's timer_tick_occurred on startup");
                        channel_manager.timer_tick_occurred();
@@ -298,7 +298,7 @@ impl BackgroundProcessor {
                                                                None
                                                        }
                                                },
                                                                None
                                                        }
                                                },
-                                               None => net_graph_msg_handler.as_ref().map(|handler| handler.network_graph())
+                                               None => p2p_gossip_sync.as_ref().map(|sync| sync.network_graph())
                                        };
 
                                        if let Some(network_graph_reference) = graph_to_prune {
                                        };
 
                                        if let Some(network_graph_reference) = graph_to_prune {
@@ -337,8 +337,8 @@ impl BackgroundProcessor {
                        }
 
                        // Persist NetworkGraph on exit
                        }
 
                        // Persist NetworkGraph on exit
-                       if let Some(ref handler) = net_graph_msg_handler {
-                               persister.persist_graph(handler.network_graph())?;
+                       if let Some(ref gossip_sync) = p2p_gossip_sync {
+                               persister.persist_graph(gossip_sync.network_graph())?;
                        }
 
                        Ok(())
                        }
 
                        Ok(())
@@ -408,7 +408,7 @@ mod tests {
        use lightning::ln::features::{ChannelFeatures, InitFeatures};
        use lightning::ln::msgs::{ChannelMessageHandler, Init};
        use lightning::ln::peer_handler::{PeerManager, MessageHandler, SocketDescriptor, IgnoringMessageHandler};
        use lightning::ln::features::{ChannelFeatures, InitFeatures};
        use lightning::ln::msgs::{ChannelMessageHandler, Init};
        use lightning::ln::peer_handler::{PeerManager, MessageHandler, SocketDescriptor, IgnoringMessageHandler};
-       use lightning::routing::network_graph::{NetworkGraph, NetGraphMsgHandler};
+       use lightning::routing::network_graph::{NetworkGraph, P2PGossipSync};
        use lightning::util::config::UserConfig;
        use lightning::util::events::{Event, MessageSendEventsProvider, MessageSendEvent};
        use lightning::util::ser::Writeable;
        use lightning::util::config::UserConfig;
        use lightning::util::events::{Event, MessageSendEventsProvider, MessageSendEvent};
        use lightning::util::ser::Writeable;
@@ -442,7 +442,7 @@ mod tests {
 
        struct Node {
                node: Arc<SimpleArcChannelManager<ChainMonitor, test_utils::TestBroadcaster, test_utils::TestFeeEstimator, test_utils::TestLogger>>,
 
        struct Node {
                node: Arc<SimpleArcChannelManager<ChainMonitor, test_utils::TestBroadcaster, test_utils::TestFeeEstimator, test_utils::TestLogger>>,
-               net_graph_msg_handler: Option<Arc<NetGraphMsgHandler<Arc<NetworkGraph>, Arc<test_utils::TestChainSource>, Arc<test_utils::TestLogger>>>>,
+               p2p_gossip_sync: Option<Arc<P2PGossipSync<Arc<NetworkGraph>, Arc<test_utils::TestChainSource>, Arc<test_utils::TestLogger>>>>,
                peer_manager: Arc<PeerManager<TestDescriptor, Arc<test_utils::TestChannelMessageHandler>, Arc<test_utils::TestRoutingMessageHandler>, Arc<test_utils::TestLogger>, IgnoringMessageHandler>>,
                chain_monitor: Arc<ChainMonitor>,
                persister: Arc<FilesystemPersister>,
                peer_manager: Arc<PeerManager<TestDescriptor, Arc<test_utils::TestChannelMessageHandler>, Arc<test_utils::TestRoutingMessageHandler>, Arc<test_utils::TestLogger>, IgnoringMessageHandler>>,
                chain_monitor: Arc<ChainMonitor>,
                persister: Arc<FilesystemPersister>,
@@ -547,12 +547,12 @@ mod tests {
                        let params = ChainParameters { network, best_block };
                        let manager = Arc::new(ChannelManager::new(fee_estimator.clone(), chain_monitor.clone(), tx_broadcaster.clone(), logger.clone(), keys_manager.clone(), UserConfig::default(), params));
                        let network_graph = Arc::new(NetworkGraph::new(genesis_block.header.block_hash()));
                        let params = ChainParameters { network, best_block };
                        let manager = Arc::new(ChannelManager::new(fee_estimator.clone(), chain_monitor.clone(), tx_broadcaster.clone(), logger.clone(), keys_manager.clone(), UserConfig::default(), params));
                        let network_graph = Arc::new(NetworkGraph::new(genesis_block.header.block_hash()));
-                       let net_graph_msg_handler = Some(Arc::new(NetGraphMsgHandler::new(network_graph.clone(), Some(chain_source.clone()), logger.clone())));
+                       let p2p_gossip_sync = Some(Arc::new(P2PGossipSync::new(network_graph.clone(), Some(chain_source.clone()), logger.clone())));
                        let msg_handler = MessageHandler { chan_handler: Arc::new(test_utils::TestChannelMessageHandler::new()), route_handler: Arc::new(test_utils::TestRoutingMessageHandler::new() )};
                        let peer_manager = Arc::new(PeerManager::new(msg_handler, keys_manager.get_node_secret(Recipient::Node).unwrap(), &seed, logger.clone(), IgnoringMessageHandler{}));
                        let scorer = Arc::new(Mutex::new(test_utils::TestScorer::with_penalty(0)));
                        let rapid_gossip_sync = None;
                        let msg_handler = MessageHandler { chan_handler: Arc::new(test_utils::TestChannelMessageHandler::new()), route_handler: Arc::new(test_utils::TestRoutingMessageHandler::new() )};
                        let peer_manager = Arc::new(PeerManager::new(msg_handler, keys_manager.get_node_secret(Recipient::Node).unwrap(), &seed, logger.clone(), IgnoringMessageHandler{}));
                        let scorer = Arc::new(Mutex::new(test_utils::TestScorer::with_penalty(0)));
                        let rapid_gossip_sync = None;
-                       let node = Node { node: manager, net_graph_msg_handler, peer_manager, chain_monitor, persister, tx_broadcaster, network_graph, logger, best_block, scorer, rapid_gossip_sync };
+                       let node = Node { node: manager, p2p_gossip_sync, peer_manager, chain_monitor, persister, tx_broadcaster, network_graph, logger, best_block, scorer, rapid_gossip_sync };
                        nodes.push(node);
                }
 
                        nodes.push(node);
                }
 
@@ -650,7 +650,7 @@ mod tests {
                let data_dir = nodes[0].persister.get_data_dir();
                let persister = Arc::new(Persister::new(data_dir));
                let event_handler = |_: &_| {};
                let data_dir = nodes[0].persister.get_data_dir();
                let persister = Arc::new(Persister::new(data_dir));
                let event_handler = |_: &_| {};
-               let bg_processor = BackgroundProcessor::start(persister, event_handler, nodes[0].chain_monitor.clone(), nodes[0].node.clone(), nodes[0].net_graph_msg_handler.clone(), nodes[0].peer_manager.clone(),  nodes[0].logger.clone(), Some(nodes[0].scorer.clone()), nodes[0].rapid_gossip_sync.clone());
+               let bg_processor = BackgroundProcessor::start(persister, event_handler, nodes[0].chain_monitor.clone(), nodes[0].node.clone(), nodes[0].p2p_gossip_sync.clone(), nodes[0].peer_manager.clone(),  nodes[0].logger.clone(), Some(nodes[0].scorer.clone()), nodes[0].rapid_gossip_sync.clone());
 
                macro_rules! check_persisted_data {
                        ($node: expr, $filepath: expr) => {
 
                macro_rules! check_persisted_data {
                        ($node: expr, $filepath: expr) => {
@@ -695,7 +695,7 @@ mod tests {
 
                // Check network graph is persisted
                let filepath = get_full_filepath("test_background_processor_persister_0".to_string(), "network_graph".to_string());
 
                // Check network graph is persisted
                let filepath = get_full_filepath("test_background_processor_persister_0".to_string(), "network_graph".to_string());
-               if let Some(ref handler) = nodes[0].net_graph_msg_handler {
+               if let Some(ref handler) = nodes[0].p2p_gossip_sync {
                        let network_graph = handler.network_graph();
                        check_persisted_data!(network_graph, filepath.clone());
                }
                        let network_graph = handler.network_graph();
                        check_persisted_data!(network_graph, filepath.clone());
                }
@@ -715,7 +715,7 @@ mod tests {
                let data_dir = nodes[0].persister.get_data_dir();
                let persister = Arc::new(Persister::new(data_dir));
                let event_handler = |_: &_| {};
                let data_dir = nodes[0].persister.get_data_dir();
                let persister = Arc::new(Persister::new(data_dir));
                let event_handler = |_: &_| {};
-               let bg_processor = BackgroundProcessor::start(persister, event_handler, nodes[0].chain_monitor.clone(), nodes[0].node.clone(), nodes[0].net_graph_msg_handler.clone(), nodes[0].peer_manager.clone(), nodes[0].logger.clone(), Some(nodes[0].scorer.clone()), nodes[0].rapid_gossip_sync.clone());
+               let bg_processor = BackgroundProcessor::start(persister, event_handler, nodes[0].chain_monitor.clone(), nodes[0].node.clone(), nodes[0].p2p_gossip_sync.clone(), nodes[0].peer_manager.clone(), nodes[0].logger.clone(), Some(nodes[0].scorer.clone()), nodes[0].rapid_gossip_sync.clone());
                loop {
                        let log_entries = nodes[0].logger.lines.lock().unwrap();
                        let desired_log = "Calling ChannelManager's timer_tick_occurred".to_string();
                loop {
                        let log_entries = nodes[0].logger.lines.lock().unwrap();
                        let desired_log = "Calling ChannelManager's timer_tick_occurred".to_string();
@@ -738,7 +738,7 @@ mod tests {
                let data_dir = nodes[0].persister.get_data_dir();
                let persister = Arc::new(Persister::new(data_dir).with_manager_error(std::io::ErrorKind::Other, "test"));
                let event_handler = |_: &_| {};
                let data_dir = nodes[0].persister.get_data_dir();
                let persister = Arc::new(Persister::new(data_dir).with_manager_error(std::io::ErrorKind::Other, "test"));
                let event_handler = |_: &_| {};
-               let bg_processor = BackgroundProcessor::start(persister, event_handler, nodes[0].chain_monitor.clone(), nodes[0].node.clone(), nodes[0].net_graph_msg_handler.clone(), nodes[0].peer_manager.clone(), nodes[0].logger.clone(), Some(nodes[0].scorer.clone()), nodes[0].rapid_gossip_sync.clone());
+               let bg_processor = BackgroundProcessor::start(persister, event_handler, nodes[0].chain_monitor.clone(), nodes[0].node.clone(), nodes[0].p2p_gossip_sync.clone(), nodes[0].peer_manager.clone(), nodes[0].logger.clone(), Some(nodes[0].scorer.clone()), nodes[0].rapid_gossip_sync.clone());
                match bg_processor.join() {
                        Ok(_) => panic!("Expected error persisting manager"),
                        Err(e) => {
                match bg_processor.join() {
                        Ok(_) => panic!("Expected error persisting manager"),
                        Err(e) => {
@@ -755,7 +755,7 @@ mod tests {
                let data_dir = nodes[0].persister.get_data_dir();
                let persister = Arc::new(Persister::new(data_dir).with_graph_error(std::io::ErrorKind::Other, "test"));
                let event_handler = |_: &_| {};
                let data_dir = nodes[0].persister.get_data_dir();
                let persister = Arc::new(Persister::new(data_dir).with_graph_error(std::io::ErrorKind::Other, "test"));
                let event_handler = |_: &_| {};
-               let bg_processor = BackgroundProcessor::start(persister, event_handler, nodes[0].chain_monitor.clone(), nodes[0].node.clone(), nodes[0].net_graph_msg_handler.clone(), nodes[0].peer_manager.clone(), nodes[0].logger.clone(), Some(nodes[0].scorer.clone()), nodes[0].rapid_gossip_sync.clone());
+               let bg_processor = BackgroundProcessor::start(persister, event_handler, nodes[0].chain_monitor.clone(), nodes[0].node.clone(), nodes[0].p2p_gossip_sync.clone(), nodes[0].peer_manager.clone(), nodes[0].logger.clone(), Some(nodes[0].scorer.clone()), nodes[0].rapid_gossip_sync.clone());
 
                match bg_processor.stop() {
                        Ok(_) => panic!("Expected error persisting network graph"),
 
                match bg_processor.stop() {
                        Ok(_) => panic!("Expected error persisting network graph"),
@@ -773,7 +773,7 @@ mod tests {
                let data_dir = nodes[0].persister.get_data_dir();
                let persister = Arc::new(Persister::new(data_dir).with_scorer_error(std::io::ErrorKind::Other, "test"));
                let event_handler = |_: &_| {};
                let data_dir = nodes[0].persister.get_data_dir();
                let persister = Arc::new(Persister::new(data_dir).with_scorer_error(std::io::ErrorKind::Other, "test"));
                let event_handler = |_: &_| {};
-               let bg_processor = BackgroundProcessor::start(persister, event_handler, nodes[0].chain_monitor.clone(), nodes[0].node.clone(), nodes[0].net_graph_msg_handler.clone(), nodes[0].peer_manager.clone(),  nodes[0].logger.clone(), Some(nodes[0].scorer.clone()), nodes[0].rapid_gossip_sync.clone());
+               let bg_processor = BackgroundProcessor::start(persister, event_handler, nodes[0].chain_monitor.clone(), nodes[0].node.clone(), nodes[0].p2p_gossip_sync.clone(), nodes[0].peer_manager.clone(),  nodes[0].logger.clone(), Some(nodes[0].scorer.clone()), nodes[0].rapid_gossip_sync.clone());
 
                match bg_processor.stop() {
                        Ok(_) => panic!("Expected error persisting scorer"),
 
                match bg_processor.stop() {
                        Ok(_) => panic!("Expected error persisting scorer"),
@@ -796,7 +796,7 @@ mod tests {
                let event_handler = move |event: &Event| {
                        sender.send(handle_funding_generation_ready!(event, channel_value)).unwrap();
                };
                let event_handler = move |event: &Event| {
                        sender.send(handle_funding_generation_ready!(event, channel_value)).unwrap();
                };
-               let bg_processor = BackgroundProcessor::start(persister, event_handler, nodes[0].chain_monitor.clone(), nodes[0].node.clone(), nodes[0].net_graph_msg_handler.clone(), nodes[0].peer_manager.clone(), nodes[0].logger.clone(), Some(nodes[0].scorer.clone()), nodes[0].rapid_gossip_sync.clone());
+               let bg_processor = BackgroundProcessor::start(persister, event_handler, nodes[0].chain_monitor.clone(), nodes[0].node.clone(), nodes[0].p2p_gossip_sync.clone(), nodes[0].peer_manager.clone(), nodes[0].logger.clone(), Some(nodes[0].scorer.clone()), nodes[0].rapid_gossip_sync.clone());
 
                // Open a channel and check that the FundingGenerationReady event was handled.
                begin_open_channel!(nodes[0], nodes[1], channel_value);
 
                // Open a channel and check that the FundingGenerationReady event was handled.
                begin_open_channel!(nodes[0], nodes[1], channel_value);
@@ -821,7 +821,7 @@ mod tests {
                let (sender, receiver) = std::sync::mpsc::sync_channel(1);
                let event_handler = move |event: &Event| sender.send(event.clone()).unwrap();
                let persister = Arc::new(Persister::new(data_dir));
                let (sender, receiver) = std::sync::mpsc::sync_channel(1);
                let event_handler = move |event: &Event| sender.send(event.clone()).unwrap();
                let persister = Arc::new(Persister::new(data_dir));
-               let bg_processor = BackgroundProcessor::start(persister, event_handler, nodes[0].chain_monitor.clone(), nodes[0].node.clone(), nodes[0].net_graph_msg_handler.clone(), nodes[0].peer_manager.clone(), nodes[0].logger.clone(), Some(nodes[0].scorer.clone()), nodes[0].rapid_gossip_sync.clone());
+               let bg_processor = BackgroundProcessor::start(persister, event_handler, nodes[0].chain_monitor.clone(), nodes[0].node.clone(), nodes[0].p2p_gossip_sync.clone(), nodes[0].peer_manager.clone(), nodes[0].logger.clone(), Some(nodes[0].scorer.clone()), nodes[0].rapid_gossip_sync.clone());
 
                // Force close the channel and check that the SpendableOutputs event was handled.
                nodes[0].node.force_close_channel(&nodes[0].node.list_channels()[0].channel_id, &nodes[1].node.get_our_node_id()).unwrap();
 
                // Force close the channel and check that the SpendableOutputs event was handled.
                nodes[0].node.force_close_channel(&nodes[0].node.list_channels()[0].channel_id, &nodes[1].node.get_our_node_id()).unwrap();
@@ -845,7 +845,7 @@ mod tests {
                let data_dir = nodes[0].persister.get_data_dir();
                let persister = Arc::new(Persister::new(data_dir));
                let event_handler = |_: &_| {};
                let data_dir = nodes[0].persister.get_data_dir();
                let persister = Arc::new(Persister::new(data_dir));
                let event_handler = |_: &_| {};
-               let bg_processor = BackgroundProcessor::start(persister, event_handler, nodes[0].chain_monitor.clone(), nodes[0].node.clone(), nodes[0].net_graph_msg_handler.clone(), nodes[0].peer_manager.clone(),  nodes[0].logger.clone(), Some(nodes[0].scorer.clone()), nodes[0].rapid_gossip_sync.clone());
+               let bg_processor = BackgroundProcessor::start(persister, event_handler, nodes[0].chain_monitor.clone(), nodes[0].node.clone(), nodes[0].p2p_gossip_sync.clone(), nodes[0].peer_manager.clone(),  nodes[0].logger.clone(), Some(nodes[0].scorer.clone()), nodes[0].rapid_gossip_sync.clone());
 
                loop {
                        let log_entries = nodes[0].logger.lines.lock().unwrap();
 
                loop {
                        let log_entries = nodes[0].logger.lines.lock().unwrap();
@@ -874,7 +874,7 @@ mod tests {
                assert_eq!(network_graph.read_only().channels().len(), 1);
 
                let event_handler = |_: &_| {};
                assert_eq!(network_graph.read_only().channels().len(), 1);
 
                let event_handler = |_: &_| {};
-               let background_processor = BackgroundProcessor::start(persister, event_handler, nodes[0].chain_monitor.clone(), nodes[0].node.clone(), nodes[0].net_graph_msg_handler.clone(), nodes[0].peer_manager.clone(), nodes[0].logger.clone(), Some(nodes[0].scorer.clone()), Some(rapid_sync.clone()));
+               let background_processor = BackgroundProcessor::start(persister, event_handler, nodes[0].chain_monitor.clone(), nodes[0].node.clone(), nodes[0].p2p_gossip_sync.clone(), nodes[0].peer_manager.clone(), nodes[0].logger.clone(), Some(nodes[0].scorer.clone()), Some(rapid_sync.clone()));
 
                loop {
                        let log_entries = nodes[0].logger.lines.lock().unwrap();
 
                loop {
                        let log_entries = nodes[0].logger.lines.lock().unwrap();
@@ -928,7 +928,7 @@ mod tests {
                let router = DefaultRouter::new(Arc::clone(&nodes[0].network_graph), Arc::clone(&nodes[0].logger), random_seed_bytes);
                let invoice_payer = Arc::new(InvoicePayer::new(Arc::clone(&nodes[0].node), router, Arc::clone(&nodes[0].scorer), Arc::clone(&nodes[0].logger), |_: &_| {}, Retry::Attempts(2)));
                let event_handler = Arc::clone(&invoice_payer);
                let router = DefaultRouter::new(Arc::clone(&nodes[0].network_graph), Arc::clone(&nodes[0].logger), random_seed_bytes);
                let invoice_payer = Arc::new(InvoicePayer::new(Arc::clone(&nodes[0].node), router, Arc::clone(&nodes[0].scorer), Arc::clone(&nodes[0].logger), |_: &_| {}, Retry::Attempts(2)));
                let event_handler = Arc::clone(&invoice_payer);
-               let bg_processor = BackgroundProcessor::start(persister, event_handler, nodes[0].chain_monitor.clone(), nodes[0].node.clone(), nodes[0].net_graph_msg_handler.clone(), nodes[0].peer_manager.clone(), nodes[0].logger.clone(), Some(nodes[0].scorer.clone()), nodes[0].rapid_gossip_sync.clone());
+               let bg_processor = BackgroundProcessor::start(persister, event_handler, nodes[0].chain_monitor.clone(), nodes[0].node.clone(), nodes[0].p2p_gossip_sync.clone(), nodes[0].peer_manager.clone(), nodes[0].logger.clone(), Some(nodes[0].scorer.clone()), nodes[0].rapid_gossip_sync.clone());
                assert!(bg_processor.stop().is_ok());
        }
 }
                assert!(bg_processor.stop().is_ok());
        }
 }
index 770fe8139413446bcc498086d00572db696f7dbc..495b507426c19bd7f31d6709da30db79c13f0dd9 100644 (file)
@@ -1901,9 +1901,9 @@ fn do_during_funding_monitor_fail(confirm_a_first: bool, restore_b_before_conf:
                (channel_id, create_chan_between_nodes_with_value_b(&nodes[1], &nodes[0], &channel_ready))
        };
        for node in nodes.iter() {
                (channel_id, create_chan_between_nodes_with_value_b(&nodes[1], &nodes[0], &channel_ready))
        };
        for node in nodes.iter() {
-               assert!(node.net_graph_msg_handler.handle_channel_announcement(&announcement).unwrap());
-               node.net_graph_msg_handler.handle_channel_update(&as_update).unwrap();
-               node.net_graph_msg_handler.handle_channel_update(&bs_update).unwrap();
+               assert!(node.gossip_sync.handle_channel_announcement(&announcement).unwrap());
+               node.gossip_sync.handle_channel_update(&as_update).unwrap();
+               node.gossip_sync.handle_channel_update(&bs_update).unwrap();
        }
 
        send_payment(&nodes[0], &[&nodes[1]], 8000000);
        }
 
        send_payment(&nodes[0], &[&nodes[1]], 8000000);
index 7b653c89d9d08c634b78922702ffb36bd3eb385f..48656c81e02eab86e956acf7b3952c9889e75823 100644 (file)
@@ -15,7 +15,7 @@ use chain::channelmonitor::ChannelMonitor;
 use chain::transaction::OutPoint;
 use ln::{PaymentPreimage, PaymentHash, PaymentSecret};
 use ln::channelmanager::{ChainParameters, ChannelManager, ChannelManagerReadArgs, RAACommitmentOrder, PaymentSendFailure, PaymentId, MIN_CLTV_EXPIRY_DELTA};
 use chain::transaction::OutPoint;
 use ln::{PaymentPreimage, PaymentHash, PaymentSecret};
 use ln::channelmanager::{ChainParameters, ChannelManager, ChannelManagerReadArgs, RAACommitmentOrder, PaymentSendFailure, PaymentId, MIN_CLTV_EXPIRY_DELTA};
-use routing::network_graph::{NetGraphMsgHandler, NetworkGraph};
+use routing::network_graph::{P2PGossipSync, NetworkGraph};
 use routing::router::{PaymentParameters, Route, get_route};
 use ln::features::{InitFeatures, InvoiceFeatures};
 use ln::msgs;
 use routing::router::{PaymentParameters, Route, get_route};
 use ln::features::{InitFeatures, InvoiceFeatures};
 use ln::msgs;
@@ -279,7 +279,7 @@ pub struct Node<'a, 'b: 'a, 'c: 'b> {
        pub keys_manager: &'b test_utils::TestKeysInterface,
        pub node: &'a ChannelManager<EnforcingSigner, &'b TestChainMonitor<'c>, &'c test_utils::TestBroadcaster, &'b test_utils::TestKeysInterface, &'c test_utils::TestFeeEstimator, &'c test_utils::TestLogger>,
        pub network_graph: &'c NetworkGraph,
        pub keys_manager: &'b test_utils::TestKeysInterface,
        pub node: &'a ChannelManager<EnforcingSigner, &'b TestChainMonitor<'c>, &'c test_utils::TestBroadcaster, &'b test_utils::TestKeysInterface, &'c test_utils::TestFeeEstimator, &'c test_utils::TestLogger>,
        pub network_graph: &'c NetworkGraph,
-       pub net_graph_msg_handler: NetGraphMsgHandler<&'c NetworkGraph, &'c test_utils::TestChainSource, &'c test_utils::TestLogger>,
+       pub gossip_sync: P2PGossipSync<&'c NetworkGraph, &'c test_utils::TestChainSource, &'c test_utils::TestLogger>,
        pub node_seed: [u8; 32],
        pub network_payment_count: Rc<RefCell<u8>>,
        pub network_chan_count: Rc<RefCell<u32>>,
        pub node_seed: [u8; 32],
        pub network_payment_count: Rc<RefCell<u8>>,
        pub network_chan_count: Rc<RefCell<u32>>,
@@ -313,13 +313,13 @@ impl<'a, 'b, 'c> Drop for Node<'a, 'b, 'c> {
                                self.network_graph.write(&mut w).unwrap();
                                let network_graph_deser = <NetworkGraph>::read(&mut io::Cursor::new(&w.0)).unwrap();
                                assert!(network_graph_deser == *self.network_graph);
                                self.network_graph.write(&mut w).unwrap();
                                let network_graph_deser = <NetworkGraph>::read(&mut io::Cursor::new(&w.0)).unwrap();
                                assert!(network_graph_deser == *self.network_graph);
-                               let net_graph_msg_handler = NetGraphMsgHandler::new(
+                               let gossip_sync = P2PGossipSync::new(
                                        &network_graph_deser, Some(self.chain_source), self.logger
                                );
                                let mut chan_progress = 0;
                                loop {
                                        &network_graph_deser, Some(self.chain_source), self.logger
                                );
                                let mut chan_progress = 0;
                                loop {
-                                       let orig_announcements = self.net_graph_msg_handler.get_next_channel_announcements(chan_progress, 255);
-                                       let deserialized_announcements = net_graph_msg_handler.get_next_channel_announcements(chan_progress, 255);
+                                       let orig_announcements = self.gossip_sync.get_next_channel_announcements(chan_progress, 255);
+                                       let deserialized_announcements = gossip_sync.get_next_channel_announcements(chan_progress, 255);
                                        assert!(orig_announcements == deserialized_announcements);
                                        chan_progress = match orig_announcements.last() {
                                                Some(announcement) => announcement.0.contents.short_channel_id + 1,
                                        assert!(orig_announcements == deserialized_announcements);
                                        chan_progress = match orig_announcements.last() {
                                                Some(announcement) => announcement.0.contents.short_channel_id + 1,
@@ -328,8 +328,8 @@ impl<'a, 'b, 'c> Drop for Node<'a, 'b, 'c> {
                                }
                                let mut node_progress = None;
                                loop {
                                }
                                let mut node_progress = None;
                                loop {
-                                       let orig_announcements = self.net_graph_msg_handler.get_next_node_announcements(node_progress.as_ref(), 255);
-                                       let deserialized_announcements = net_graph_msg_handler.get_next_node_announcements(node_progress.as_ref(), 255);
+                                       let orig_announcements = self.gossip_sync.get_next_node_announcements(node_progress.as_ref(), 255);
+                                       let deserialized_announcements = gossip_sync.get_next_node_announcements(node_progress.as_ref(), 255);
                                        assert!(orig_announcements == deserialized_announcements);
                                        node_progress = match orig_announcements.last() {
                                                Some(announcement) => Some(announcement.contents.node_id),
                                        assert!(orig_announcements == deserialized_announcements);
                                        node_progress = match orig_announcements.last() {
                                                Some(announcement) => Some(announcement.contents.node_id),
@@ -876,11 +876,11 @@ pub fn update_nodes_with_chan_announce<'a, 'b, 'c, 'd>(nodes: &'a Vec<Node<'b, '
        };
 
        for node in nodes {
        };
 
        for node in nodes {
-               assert!(node.net_graph_msg_handler.handle_channel_announcement(ann).unwrap());
-               node.net_graph_msg_handler.handle_channel_update(upd_1).unwrap();
-               node.net_graph_msg_handler.handle_channel_update(upd_2).unwrap();
-               node.net_graph_msg_handler.handle_node_announcement(&a_node_announcement).unwrap();
-               node.net_graph_msg_handler.handle_node_announcement(&b_node_announcement).unwrap();
+               assert!(node.gossip_sync.handle_channel_announcement(ann).unwrap());
+               node.gossip_sync.handle_channel_update(upd_1).unwrap();
+               node.gossip_sync.handle_channel_update(upd_2).unwrap();
+               node.gossip_sync.handle_node_announcement(&a_node_announcement).unwrap();
+               node.gossip_sync.handle_node_announcement(&b_node_announcement).unwrap();
 
                // Note that channel_updates are also delivered to ChannelManagers to ensure we have
                // forwarding info for local channels even if its not accepted in the network graph.
 
                // Note that channel_updates are also delivered to ChannelManagers to ensure we have
                // forwarding info for local channels even if its not accepted in the network graph.
@@ -1992,11 +1992,11 @@ pub fn create_network<'a, 'b: 'a, 'c: 'b>(node_count: usize, cfgs: &'b Vec<NodeC
        let connect_style = Rc::new(RefCell::new(ConnectStyle::random_style()));
 
        for i in 0..node_count {
        let connect_style = Rc::new(RefCell::new(ConnectStyle::random_style()));
 
        for i in 0..node_count {
-               let net_graph_msg_handler = NetGraphMsgHandler::new(cfgs[i].network_graph, None, cfgs[i].logger);
+               let gossip_sync = P2PGossipSync::new(cfgs[i].network_graph, None, cfgs[i].logger);
                nodes.push(Node{
                        chain_source: cfgs[i].chain_source, tx_broadcaster: cfgs[i].tx_broadcaster,
                        chain_monitor: &cfgs[i].chain_monitor, keys_manager: &cfgs[i].keys_manager,
                nodes.push(Node{
                        chain_source: cfgs[i].chain_source, tx_broadcaster: cfgs[i].tx_broadcaster,
                        chain_monitor: &cfgs[i].chain_monitor, keys_manager: &cfgs[i].keys_manager,
-                       node: &chan_mgrs[i], network_graph: &cfgs[i].network_graph, net_graph_msg_handler,
+                       node: &chan_mgrs[i], network_graph: &cfgs[i].network_graph, gossip_sync,
                        node_seed: cfgs[i].node_seed, network_chan_count: chan_count.clone(),
                        network_payment_count: payment_count.clone(), logger: cfgs[i].logger,
                        blocks: Arc::clone(&cfgs[i].tx_broadcaster.blocks),
                        node_seed: cfgs[i].node_seed, network_chan_count: chan_count.clone(),
                        network_payment_count: payment_count.clone(), logger: cfgs[i].logger,
                        blocks: Arc::clone(&cfgs[i].tx_broadcaster.blocks),
@@ -2160,8 +2160,8 @@ pub fn handle_announce_close_broadcast_events<'a, 'b, 'c>(nodes: &Vec<Node<'a, '
        }
 
        for node in nodes {
        }
 
        for node in nodes {
-               node.net_graph_msg_handler.handle_channel_update(&as_update).unwrap();
-               node.net_graph_msg_handler.handle_channel_update(&bs_update).unwrap();
+               node.gossip_sync.handle_channel_update(&as_update).unwrap();
+               node.gossip_sync.handle_channel_update(&bs_update).unwrap();
        }
 }
 
        }
 }
 
index d1dbad4720b814db3fb89476e0e8e8b7cee22193..c7365452d67e5a7d80fb2661f48bcfb7adefbc67 100644 (file)
@@ -2347,8 +2347,8 @@ fn channel_monitor_network_test() {
                check_preimage_claim(&nodes[4], &node_txn);
                (close_chan_update_1, close_chan_update_2)
        };
                check_preimage_claim(&nodes[4], &node_txn);
                (close_chan_update_1, close_chan_update_2)
        };
-       nodes[3].net_graph_msg_handler.handle_channel_update(&close_chan_update_2).unwrap();
-       nodes[4].net_graph_msg_handler.handle_channel_update(&close_chan_update_1).unwrap();
+       nodes[3].gossip_sync.handle_channel_update(&close_chan_update_2).unwrap();
+       nodes[4].gossip_sync.handle_channel_update(&close_chan_update_1).unwrap();
        assert_eq!(nodes[3].node.list_channels().len(), 0);
        assert_eq!(nodes[4].node.list_channels().len(), 0);
 
        assert_eq!(nodes[3].node.list_channels().len(), 0);
        assert_eq!(nodes[4].node.list_channels().len(), 0);
 
@@ -3978,9 +3978,9 @@ fn test_funding_peer_disconnect() {
        };
 
        // Provide the channel announcement and public updates to the network graph
        };
 
        // Provide the channel announcement and public updates to the network graph
-       nodes[0].net_graph_msg_handler.handle_channel_announcement(&chan_announcement).unwrap();
-       nodes[0].net_graph_msg_handler.handle_channel_update(&bs_update).unwrap();
-       nodes[0].net_graph_msg_handler.handle_channel_update(&as_update).unwrap();
+       nodes[0].gossip_sync.handle_channel_announcement(&chan_announcement).unwrap();
+       nodes[0].gossip_sync.handle_channel_update(&bs_update).unwrap();
+       nodes[0].gossip_sync.handle_channel_update(&as_update).unwrap();
 
        let (route, _, _, _) = get_route_and_payment_hash!(nodes[0], nodes[1], 1000000);
        let payment_preimage = send_along_route(&nodes[0], route, &[&nodes[1]], 1000000).0;
 
        let (route, _, _, _) = get_route_and_payment_hash!(nodes[0], nodes[1], 1000000);
        let payment_preimage = send_along_route(&nodes[0], route, &[&nodes[1]], 1000000).0;
@@ -4421,9 +4421,9 @@ fn test_no_txn_manager_serialize_deserialize() {
        let (channel_ready, _) = create_chan_between_nodes_with_value_confirm(&nodes[0], &nodes[1], &tx);
        let (announcement, as_update, bs_update) = create_chan_between_nodes_with_value_b(&nodes[0], &nodes[1], &channel_ready);
        for node in nodes.iter() {
        let (channel_ready, _) = create_chan_between_nodes_with_value_confirm(&nodes[0], &nodes[1], &tx);
        let (announcement, as_update, bs_update) = create_chan_between_nodes_with_value_b(&nodes[0], &nodes[1], &channel_ready);
        for node in nodes.iter() {
-               assert!(node.net_graph_msg_handler.handle_channel_announcement(&announcement).unwrap());
-               node.net_graph_msg_handler.handle_channel_update(&as_update).unwrap();
-               node.net_graph_msg_handler.handle_channel_update(&bs_update).unwrap();
+               assert!(node.gossip_sync.handle_channel_announcement(&announcement).unwrap());
+               node.gossip_sync.handle_channel_update(&as_update).unwrap();
+               node.gossip_sync.handle_channel_update(&bs_update).unwrap();
        }
 
        send_payment(&nodes[0], &[&nodes[1]], 1000000);
        }
 
        send_payment(&nodes[0], &[&nodes[1]], 1000000);
@@ -4541,9 +4541,9 @@ fn test_manager_serialize_deserialize_events() {
        let (channel_ready, _) = create_chan_between_nodes_with_value_confirm(&nodes[0], &nodes[1], &tx);
        let (announcement, as_update, bs_update) = create_chan_between_nodes_with_value_b(&nodes[0], &nodes[1], &channel_ready);
        for node in nodes.iter() {
        let (channel_ready, _) = create_chan_between_nodes_with_value_confirm(&nodes[0], &nodes[1], &tx);
        let (announcement, as_update, bs_update) = create_chan_between_nodes_with_value_b(&nodes[0], &nodes[1], &channel_ready);
        for node in nodes.iter() {
-               assert!(node.net_graph_msg_handler.handle_channel_announcement(&announcement).unwrap());
-               node.net_graph_msg_handler.handle_channel_update(&as_update).unwrap();
-               node.net_graph_msg_handler.handle_channel_update(&bs_update).unwrap();
+               assert!(node.gossip_sync.handle_channel_announcement(&announcement).unwrap());
+               node.gossip_sync.handle_channel_update(&as_update).unwrap();
+               node.gossip_sync.handle_channel_update(&bs_update).unwrap();
        }
 
        send_payment(&nodes[0], &[&nodes[1]], 1000000);
        }
 
        send_payment(&nodes[0], &[&nodes[1]], 1000000);
index 1e5f49f07df6a0cc5056e6ea26545cfac33d04ec..932ca70b00f1f9cf22a47f51cd79beaff5bc54dc 100644 (file)
@@ -9,14 +9,17 @@
 
 //! High level lightning structs and impls live here.
 //!
 
 //! High level lightning structs and impls live here.
 //!
-//! You probably want to create a channelmanager::ChannelManager, and a routing::NetGraphMsgHandler first.
+//! You probably want to create a [`ChannelManager`], and a [`P2PGossipSync`] first.
 //! Then, you probably want to pass them both on to a peer_handler::PeerManager and use that to
 //! create/manage connections and call get_and_clear_pending_events after each action, handling
 //! them appropriately.
 //!
 //! Then, you probably want to pass them both on to a peer_handler::PeerManager and use that to
 //! create/manage connections and call get_and_clear_pending_events after each action, handling
 //! them appropriately.
 //!
-//! When you want to open/close a channel or send a payment, call into your ChannelManager and when
-//! you want to learn things about the network topology (eg get a route for sending a payment),
-//! call into your NetGraphMsgHandler.
+//! When you want to open/close a channel or send a payment, call into your [`ChannelManager`] and
+//! when you want to learn things about the network topology (eg get a route for sending a payment),
+//! call into your [`P2PGossipSync`].
+//!
+//! [`ChannelManager`]: channelmanager::ChannelManager
+//! [`P2PGossipSync`]: crate::routing::network_graph::P2PGossipSync
 
 #[cfg(any(test, feature = "_test_utils"))]
 #[macro_use]
 
 #[cfg(any(test, feature = "_test_utils"))]
 #[macro_use]
index 68a7ef952702b31436ea18ff27bb83f3b67b3fe3..160c397bd9bdeea44fe8197ad3b9b3a638dff0fd 100644 (file)
@@ -12,8 +12,8 @@
 //! Instead of actually servicing sockets ourselves we require that you implement the
 //! SocketDescriptor interface and use that to receive actions which you should perform on the
 //! socket, and call into PeerManager with bytes read from the socket. The PeerManager will then
 //! Instead of actually servicing sockets ourselves we require that you implement the
 //! SocketDescriptor interface and use that to receive actions which you should perform on the
 //! socket, and call into PeerManager with bytes read from the socket. The PeerManager will then
-//! call into the provided message handlers (probably a ChannelManager and NetGraphmsgHandler) with messages
-//! they should handle, and encoding/sending response messages.
+//! call into the provided message handlers (probably a ChannelManager and P2PGossipSync) with
+//! messages they should handle, and encoding/sending response messages.
 
 use bitcoin::secp256k1::{self, Secp256k1, SecretKey, PublicKey};
 
 
 use bitcoin::secp256k1::{self, Secp256k1, SecretKey, PublicKey};
 
@@ -28,7 +28,7 @@ use ln::wire::Encode;
 use util::atomic_counter::AtomicCounter;
 use util::events::{MessageSendEvent, MessageSendEventsProvider};
 use util::logger::Logger;
 use util::atomic_counter::AtomicCounter;
 use util::events::{MessageSendEvent, MessageSendEventsProvider};
 use util::logger::Logger;
-use routing::network_graph::{NetworkGraph, NetGraphMsgHandler};
+use routing::network_graph::{NetworkGraph, P2PGossipSync};
 
 use prelude::*;
 use io;
 
 use prelude::*;
 use io;
@@ -208,10 +208,9 @@ pub struct MessageHandler<CM: Deref, RM: Deref> where
        /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
        pub chan_handler: CM,
        /// A message handler which handles messages updating our knowledge of the network channel
        /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
        pub chan_handler: CM,
        /// A message handler which handles messages updating our knowledge of the network channel
-       /// graph. Usually this is just a [`NetGraphMsgHandler`] object or an
-       /// [`IgnoringMessageHandler`].
+       /// graph. Usually this is just a [`P2PGossipSync`] object or an [`IgnoringMessageHandler`].
        ///
        ///
-       /// [`NetGraphMsgHandler`]: crate::routing::network_graph::NetGraphMsgHandler
+       /// [`P2PGossipSync`]: crate::routing::network_graph::P2PGossipSync
        pub route_handler: RM,
 }
 
        pub route_handler: RM,
 }
 
@@ -388,7 +387,7 @@ impl Peer {
 /// issues such as overly long function definitions.
 ///
 /// (C-not exported) as Arcs don't make sense in bindings
 /// issues such as overly long function definitions.
 ///
 /// (C-not exported) as Arcs don't make sense in bindings
-pub type SimpleArcPeerManager<SD, M, T, F, C, L> = PeerManager<SD, Arc<SimpleArcChannelManager<M, T, F, L>>, Arc<NetGraphMsgHandler<Arc<NetworkGraph>, Arc<C>, Arc<L>>>, Arc<L>, Arc<IgnoringMessageHandler>>;
+pub type SimpleArcPeerManager<SD, M, T, F, C, L> = PeerManager<SD, Arc<SimpleArcChannelManager<M, T, F, L>>, Arc<P2PGossipSync<Arc<NetworkGraph>, Arc<C>, Arc<L>>>, Arc<L>, Arc<IgnoringMessageHandler>>;
 
 /// SimpleRefPeerManager is a type alias for a PeerManager reference, and is the reference
 /// counterpart to the SimpleArcPeerManager type alias. Use this type by default when you don't
 
 /// SimpleRefPeerManager is a type alias for a PeerManager reference, and is the reference
 /// counterpart to the SimpleArcPeerManager type alias. Use this type by default when you don't
@@ -398,7 +397,7 @@ pub type SimpleArcPeerManager<SD, M, T, F, C, L> = PeerManager<SD, Arc<SimpleArc
 /// helps with issues such as long function definitions.
 ///
 /// (C-not exported) as Arcs don't make sense in bindings
 /// helps with issues such as long function definitions.
 ///
 /// (C-not exported) as Arcs don't make sense in bindings
-pub type SimpleRefPeerManager<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, SD, M, T, F, C, L> = PeerManager<SD, SimpleRefChannelManager<'a, 'b, 'c, 'd, 'e, M, T, F, L>, &'e NetGraphMsgHandler<&'g NetworkGraph, &'h C, &'f L>, &'f L, IgnoringMessageHandler>;
+pub type SimpleRefPeerManager<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, SD, M, T, F, C, L> = PeerManager<SD, SimpleRefChannelManager<'a, 'b, 'c, 'd, 'e, M, T, F, L>, &'e P2PGossipSync<&'g NetworkGraph, &'h C, &'f L>, &'f L, IgnoringMessageHandler>;
 
 /// A PeerManager manages a set of peers, described by their [`SocketDescriptor`] and marshalls
 /// socket events into messages which it passes on to its [`MessageHandler`].
 
 /// A PeerManager manages a set of peers, described by their [`SocketDescriptor`] and marshalls
 /// socket events into messages which it passes on to its [`MessageHandler`].
index 754e20a4ff11ba0c68a891059a683705892849ff..81bedbabb479241259efd67cb46295e946cb9a75 100644 (file)
@@ -236,9 +236,9 @@ fn do_test_1_conf_open(connect_style: ConnectStyle) {
        assert_eq!(announcement, bs_announcement);
 
        for node in nodes {
        assert_eq!(announcement, bs_announcement);
 
        for node in nodes {
-               assert!(node.net_graph_msg_handler.handle_channel_announcement(&announcement).unwrap());
-               node.net_graph_msg_handler.handle_channel_update(&as_update).unwrap();
-               node.net_graph_msg_handler.handle_channel_update(&bs_update).unwrap();
+               assert!(node.gossip_sync.handle_channel_announcement(&announcement).unwrap());
+               node.gossip_sync.handle_channel_update(&as_update).unwrap();
+               node.gossip_sync.handle_channel_update(&bs_update).unwrap();
        }
 }
 #[test]
        }
 }
 #[test]
index 7cbe373f5013f884f83c11d193fce009835ae705..0fccb3253c73dd9107a45dd2e3849fcd9dcf8ed7 100644 (file)
@@ -196,7 +196,7 @@ impl_writeable_tlv_based_enum_upgradable!(NetworkUpdate,
        },
 );
 
        },
 );
 
-impl<G: Deref<Target=NetworkGraph>, C: Deref, L: Deref> EventHandler for NetGraphMsgHandler<G, C, L>
+impl<G: Deref<Target=NetworkGraph>, C: Deref, L: Deref> EventHandler for P2PGossipSync<G, C, L>
 where C::Target: chain::Access, L::Target: Logger {
        fn handle_event(&self, event: &Event) {
                if let Event::PaymentPathFailed { payment_hash: _, rejected_by_dest: _, network_update, .. } = event {
 where C::Target: chain::Access, L::Target: Logger {
        fn handle_event(&self, event: &Event) {
                if let Event::PaymentPathFailed { payment_hash: _, rejected_by_dest: _, network_update, .. } = event {
@@ -215,7 +215,7 @@ where C::Target: chain::Access, L::Target: Logger {
 ///
 /// Serves as an [`EventHandler`] for applying updates from [`Event::PaymentPathFailed`] to the
 /// [`NetworkGraph`].
 ///
 /// Serves as an [`EventHandler`] for applying updates from [`Event::PaymentPathFailed`] to the
 /// [`NetworkGraph`].
-pub struct NetGraphMsgHandler<G: Deref<Target=NetworkGraph>, C: Deref, L: Deref>
+pub struct P2PGossipSync<G: Deref<Target=NetworkGraph>, C: Deref, L: Deref>
 where C::Target: chain::Access, L::Target: Logger
 {
        secp_ctx: Secp256k1<secp256k1::VerifyOnly>,
 where C::Target: chain::Access, L::Target: Logger
 {
        secp_ctx: Secp256k1<secp256k1::VerifyOnly>,
@@ -226,7 +226,7 @@ where C::Target: chain::Access, L::Target: Logger
        logger: L,
 }
 
        logger: L,
 }
 
-impl<G: Deref<Target=NetworkGraph>, C: Deref, L: Deref> NetGraphMsgHandler<G, C, L>
+impl<G: Deref<Target=NetworkGraph>, C: Deref, L: Deref> P2PGossipSync<G, C, L>
 where C::Target: chain::Access, L::Target: Logger
 {
        /// Creates a new tracker of the actual state of the network of channels and nodes,
 where C::Target: chain::Access, L::Target: Logger
 {
        /// Creates a new tracker of the actual state of the network of channels and nodes,
@@ -235,7 +235,7 @@ where C::Target: chain::Access, L::Target: Logger
        /// channel data is correct, and that the announcement is signed with
        /// channel owners' keys.
        pub fn new(network_graph: G, chain_access: Option<C>, logger: L) -> Self {
        /// channel data is correct, and that the announcement is signed with
        /// channel owners' keys.
        pub fn new(network_graph: G, chain_access: Option<C>, logger: L) -> Self {
-               NetGraphMsgHandler {
+               P2PGossipSync {
                        secp_ctx: Secp256k1::verification_only(),
                        network_graph,
                        full_syncs_requested: AtomicUsize::new(0),
                        secp_ctx: Secp256k1::verification_only(),
                        network_graph,
                        full_syncs_requested: AtomicUsize::new(0),
@@ -253,7 +253,7 @@ where C::Target: chain::Access, L::Target: Logger
        }
 
        /// Gets a reference to the underlying [`NetworkGraph`] which was provided in
        }
 
        /// Gets a reference to the underlying [`NetworkGraph`] which was provided in
-       /// [`NetGraphMsgHandler::new`].
+       /// [`P2PGossipSync::new`].
        ///
        /// (C-not exported) as bindings don't support a reference-to-a-reference yet
        pub fn network_graph(&self) -> &G {
        ///
        /// (C-not exported) as bindings don't support a reference-to-a-reference yet
        pub fn network_graph(&self) -> &G {
@@ -316,7 +316,7 @@ macro_rules! secp_verify_sig {
        };
 }
 
        };
 }
 
-impl<G: Deref<Target=NetworkGraph>, C: Deref, L: Deref> RoutingMessageHandler for NetGraphMsgHandler<G, C, L>
+impl<G: Deref<Target=NetworkGraph>, C: Deref, L: Deref> RoutingMessageHandler for P2PGossipSync<G, C, L>
 where C::Target: chain::Access, L::Target: Logger
 {
        fn handle_node_announcement(&self, msg: &msgs::NodeAnnouncement) -> Result<bool, LightningError> {
 where C::Target: chain::Access, L::Target: Logger
 {
        fn handle_node_announcement(&self, msg: &msgs::NodeAnnouncement) -> Result<bool, LightningError> {
@@ -605,7 +605,7 @@ where C::Target: chain::Access, L::Target: Logger
        }
 }
 
        }
 }
 
-impl<G: Deref<Target=NetworkGraph>, C: Deref, L: Deref> MessageSendEventsProvider for NetGraphMsgHandler<G, C, L>
+impl<G: Deref<Target=NetworkGraph>, C: Deref, L: Deref> MessageSendEventsProvider for P2PGossipSync<G, C, L>
 where
        C::Target: chain::Access,
        L::Target: Logger,
 where
        C::Target: chain::Access,
        L::Target: Logger,
@@ -1102,7 +1102,7 @@ impl NetworkGraph {
        /// For an already known node (from channel announcements), update its stored properties from a
        /// given node announcement.
        ///
        /// For an already known node (from channel announcements), update its stored properties from a
        /// given node announcement.
        ///
-       /// You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's
+       /// You probably don't want to call this directly, instead relying on a P2PGossipSync's
        /// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
        /// routing messages from a source using a protocol other than the lightning P2P protocol.
        pub fn update_node_from_announcement<T: secp256k1::Verification>(&self, msg: &msgs::NodeAnnouncement, secp_ctx: &Secp256k1<T>) -> Result<(), LightningError> {
        /// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
        /// routing messages from a source using a protocol other than the lightning P2P protocol.
        pub fn update_node_from_announcement<T: secp256k1::Verification>(&self, msg: &msgs::NodeAnnouncement, secp_ctx: &Secp256k1<T>) -> Result<(), LightningError> {
@@ -1154,7 +1154,7 @@ impl NetworkGraph {
 
        /// Store or update channel info from a channel announcement.
        ///
 
        /// Store or update channel info from a channel announcement.
        ///
-       /// You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's
+       /// You probably don't want to call this directly, instead relying on a P2PGossipSync's
        /// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
        /// routing messages from a source using a protocol other than the lightning P2P protocol.
        ///
        /// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
        /// routing messages from a source using a protocol other than the lightning P2P protocol.
        ///
@@ -1426,7 +1426,7 @@ impl NetworkGraph {
        /// For an already known (from announcement) channel, update info about one of the directions
        /// of the channel.
        ///
        /// For an already known (from announcement) channel, update info about one of the directions
        /// of the channel.
        ///
-       /// You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's
+       /// You probably don't want to call this directly, instead relying on a P2PGossipSync's
        /// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
        /// routing messages from a source using a protocol other than the lightning P2P protocol.
        ///
        /// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
        /// routing messages from a source using a protocol other than the lightning P2P protocol.
        ///
@@ -1643,7 +1643,7 @@ mod tests {
        use chain;
        use ln::PaymentHash;
        use ln::features::{ChannelFeatures, InitFeatures, NodeFeatures};
        use chain;
        use ln::PaymentHash;
        use ln::features::{ChannelFeatures, InitFeatures, NodeFeatures};
-       use routing::network_graph::{NetGraphMsgHandler, NetworkGraph, NetworkUpdate, MAX_EXCESS_BYTES_FOR_RELAY};
+       use routing::network_graph::{P2PGossipSync, NetworkGraph, NetworkUpdate, MAX_EXCESS_BYTES_FOR_RELAY};
        use ln::msgs::{Init, OptionalField, RoutingMessageHandler, UnsignedNodeAnnouncement, NodeAnnouncement,
                UnsignedChannelAnnouncement, ChannelAnnouncement, UnsignedChannelUpdate, ChannelUpdate,
                ReplyChannelRange, QueryChannelRange, QueryShortChannelIds, MAX_VALUE_MSAT};
        use ln::msgs::{Init, OptionalField, RoutingMessageHandler, UnsignedNodeAnnouncement, NodeAnnouncement,
                UnsignedChannelAnnouncement, ChannelAnnouncement, UnsignedChannelUpdate, ChannelUpdate,
                ReplyChannelRange, QueryChannelRange, QueryShortChannelIds, MAX_VALUE_MSAT};
@@ -1678,27 +1678,27 @@ mod tests {
                NetworkGraph::new(genesis_hash)
        }
 
                NetworkGraph::new(genesis_hash)
        }
 
-       fn create_net_graph_msg_handler(network_graph: &NetworkGraph) -> (
-               Secp256k1<All>, NetGraphMsgHandler<&NetworkGraph, Arc<test_utils::TestChainSource>, Arc<test_utils::TestLogger>>
+       fn create_gossip_sync(network_graph: &NetworkGraph) -> (
+               Secp256k1<All>, P2PGossipSync<&NetworkGraph, Arc<test_utils::TestChainSource>, Arc<test_utils::TestLogger>>
        ) {
                let secp_ctx = Secp256k1::new();
                let logger = Arc::new(test_utils::TestLogger::new());
        ) {
                let secp_ctx = Secp256k1::new();
                let logger = Arc::new(test_utils::TestLogger::new());
-               let net_graph_msg_handler = NetGraphMsgHandler::new(network_graph, None, Arc::clone(&logger));
-               (secp_ctx, net_graph_msg_handler)
+               let gossip_sync = P2PGossipSync::new(network_graph, None, Arc::clone(&logger));
+               (secp_ctx, gossip_sync)
        }
 
        #[test]
        fn request_full_sync_finite_times() {
                let network_graph = create_network_graph();
        }
 
        #[test]
        fn request_full_sync_finite_times() {
                let network_graph = create_network_graph();
-               let (secp_ctx, net_graph_msg_handler) = create_net_graph_msg_handler(&network_graph);
+               let (secp_ctx, gossip_sync) = create_gossip_sync(&network_graph);
                let node_id = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&hex::decode("0202020202020202020202020202020202020202020202020202020202020202").unwrap()[..]).unwrap());
 
                let node_id = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&hex::decode("0202020202020202020202020202020202020202020202020202020202020202").unwrap()[..]).unwrap());
 
-               assert!(net_graph_msg_handler.should_request_full_sync(&node_id));
-               assert!(net_graph_msg_handler.should_request_full_sync(&node_id));
-               assert!(net_graph_msg_handler.should_request_full_sync(&node_id));
-               assert!(net_graph_msg_handler.should_request_full_sync(&node_id));
-               assert!(net_graph_msg_handler.should_request_full_sync(&node_id));
-               assert!(!net_graph_msg_handler.should_request_full_sync(&node_id));
+               assert!(gossip_sync.should_request_full_sync(&node_id));
+               assert!(gossip_sync.should_request_full_sync(&node_id));
+               assert!(gossip_sync.should_request_full_sync(&node_id));
+               assert!(gossip_sync.should_request_full_sync(&node_id));
+               assert!(gossip_sync.should_request_full_sync(&node_id));
+               assert!(!gossip_sync.should_request_full_sync(&node_id));
        }
 
        fn get_signed_node_announcement<F: Fn(&mut UnsignedNodeAnnouncement)>(f: F, node_key: &SecretKey, secp_ctx: &Secp256k1<secp256k1::All>) -> NodeAnnouncement {
        }
 
        fn get_signed_node_announcement<F: Fn(&mut UnsignedNodeAnnouncement)>(f: F, node_key: &SecretKey, secp_ctx: &Secp256k1<secp256k1::All>) -> NodeAnnouncement {
@@ -1783,14 +1783,14 @@ mod tests {
        #[test]
        fn handling_node_announcements() {
                let network_graph = create_network_graph();
        #[test]
        fn handling_node_announcements() {
                let network_graph = create_network_graph();
-               let (secp_ctx, net_graph_msg_handler) = create_net_graph_msg_handler(&network_graph);
+               let (secp_ctx, gossip_sync) = create_gossip_sync(&network_graph);
 
                let node_1_privkey = &SecretKey::from_slice(&[42; 32]).unwrap();
                let node_2_privkey = &SecretKey::from_slice(&[41; 32]).unwrap();
                let zero_hash = Sha256dHash::hash(&[0; 32]);
 
                let valid_announcement = get_signed_node_announcement(|_| {}, node_1_privkey, &secp_ctx);
 
                let node_1_privkey = &SecretKey::from_slice(&[42; 32]).unwrap();
                let node_2_privkey = &SecretKey::from_slice(&[41; 32]).unwrap();
                let zero_hash = Sha256dHash::hash(&[0; 32]);
 
                let valid_announcement = get_signed_node_announcement(|_| {}, node_1_privkey, &secp_ctx);
-               match net_graph_msg_handler.handle_node_announcement(&valid_announcement) {
+               match gossip_sync.handle_node_announcement(&valid_announcement) {
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!("No existing channels for node_announcement", e.err)
                };
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!("No existing channels for node_announcement", e.err)
                };
@@ -1798,19 +1798,19 @@ mod tests {
                {
                        // Announce a channel to add a corresponding node.
                        let valid_announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_2_privkey, &secp_ctx);
                {
                        // Announce a channel to add a corresponding node.
                        let valid_announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_2_privkey, &secp_ctx);
-                       match net_graph_msg_handler.handle_channel_announcement(&valid_announcement) {
+                       match gossip_sync.handle_channel_announcement(&valid_announcement) {
                                Ok(res) => assert!(res),
                                _ => panic!()
                        };
                }
 
                                Ok(res) => assert!(res),
                                _ => panic!()
                        };
                }
 
-               match net_graph_msg_handler.handle_node_announcement(&valid_announcement) {
+               match gossip_sync.handle_node_announcement(&valid_announcement) {
                        Ok(res) => assert!(res),
                        Err(_) => panic!()
                };
 
                let fake_msghash = hash_to_message!(&zero_hash);
                        Ok(res) => assert!(res),
                        Err(_) => panic!()
                };
 
                let fake_msghash = hash_to_message!(&zero_hash);
-               match net_graph_msg_handler.handle_node_announcement(
+               match gossip_sync.handle_node_announcement(
                        &NodeAnnouncement {
                                signature: secp_ctx.sign_ecdsa(&fake_msghash, node_1_privkey),
                                contents: valid_announcement.contents.clone()
                        &NodeAnnouncement {
                                signature: secp_ctx.sign_ecdsa(&fake_msghash, node_1_privkey),
                                contents: valid_announcement.contents.clone()
@@ -1824,7 +1824,7 @@ mod tests {
                        unsigned_announcement.excess_data.resize(MAX_EXCESS_BYTES_FOR_RELAY + 1, 0);
                }, node_1_privkey, &secp_ctx);
                // Return false because contains excess data.
                        unsigned_announcement.excess_data.resize(MAX_EXCESS_BYTES_FOR_RELAY + 1, 0);
                }, node_1_privkey, &secp_ctx);
                // Return false because contains excess data.
-               match net_graph_msg_handler.handle_node_announcement(&announcement_with_data) {
+               match gossip_sync.handle_node_announcement(&announcement_with_data) {
                        Ok(res) => assert!(!res),
                        Err(_) => panic!()
                };
                        Ok(res) => assert!(!res),
                        Err(_) => panic!()
                };
@@ -1834,7 +1834,7 @@ mod tests {
                let outdated_announcement = get_signed_node_announcement(|unsigned_announcement| {
                        unsigned_announcement.timestamp += 1000 - 10;
                }, node_1_privkey, &secp_ctx);
                let outdated_announcement = get_signed_node_announcement(|unsigned_announcement| {
                        unsigned_announcement.timestamp += 1000 - 10;
                }, node_1_privkey, &secp_ctx);
-               match net_graph_msg_handler.handle_node_announcement(&outdated_announcement) {
+               match gossip_sync.handle_node_announcement(&outdated_announcement) {
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "Update older than last processed update")
                };
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "Update older than last processed update")
                };
@@ -1853,8 +1853,8 @@ mod tests {
 
                // Test if the UTXO lookups were not supported
                let network_graph = NetworkGraph::new(genesis_block(Network::Testnet).header.block_hash());
 
                // Test if the UTXO lookups were not supported
                let network_graph = NetworkGraph::new(genesis_block(Network::Testnet).header.block_hash());
-               let mut net_graph_msg_handler = NetGraphMsgHandler::new(&network_graph, None, Arc::clone(&logger));
-               match net_graph_msg_handler.handle_channel_announcement(&valid_announcement) {
+               let mut gossip_sync = P2PGossipSync::new(&network_graph, None, Arc::clone(&logger));
+               match gossip_sync.handle_channel_announcement(&valid_announcement) {
                        Ok(res) => assert!(res),
                        _ => panic!()
                };
                        Ok(res) => assert!(res),
                        _ => panic!()
                };
@@ -1868,7 +1868,7 @@ mod tests {
 
                // If we receive announcement for the same channel (with UTXO lookups disabled),
                // drop new one on the floor, since we can't see any changes.
 
                // If we receive announcement for the same channel (with UTXO lookups disabled),
                // drop new one on the floor, since we can't see any changes.
-               match net_graph_msg_handler.handle_channel_announcement(&valid_announcement) {
+               match gossip_sync.handle_channel_announcement(&valid_announcement) {
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "Already have knowledge of channel")
                };
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "Already have knowledge of channel")
                };
@@ -1877,12 +1877,12 @@ mod tests {
                let chain_source = Arc::new(test_utils::TestChainSource::new(Network::Testnet));
                *chain_source.utxo_ret.lock().unwrap() = Err(chain::AccessError::UnknownTx);
                let network_graph = NetworkGraph::new(genesis_block(Network::Testnet).header.block_hash());
                let chain_source = Arc::new(test_utils::TestChainSource::new(Network::Testnet));
                *chain_source.utxo_ret.lock().unwrap() = Err(chain::AccessError::UnknownTx);
                let network_graph = NetworkGraph::new(genesis_block(Network::Testnet).header.block_hash());
-               net_graph_msg_handler = NetGraphMsgHandler::new(&network_graph, Some(chain_source.clone()), Arc::clone(&logger));
+               gossip_sync = P2PGossipSync::new(&network_graph, Some(chain_source.clone()), Arc::clone(&logger));
 
                let valid_announcement = get_signed_channel_announcement(|unsigned_announcement| {
                        unsigned_announcement.short_channel_id += 1;
                }, node_1_privkey, node_2_privkey, &secp_ctx);
 
                let valid_announcement = get_signed_channel_announcement(|unsigned_announcement| {
                        unsigned_announcement.short_channel_id += 1;
                }, node_1_privkey, node_2_privkey, &secp_ctx);
-               match net_graph_msg_handler.handle_channel_announcement(&valid_announcement) {
+               match gossip_sync.handle_channel_announcement(&valid_announcement) {
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "Channel announced without corresponding UTXO entry")
                };
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "Channel announced without corresponding UTXO entry")
                };
@@ -1892,7 +1892,7 @@ mod tests {
                let valid_announcement = get_signed_channel_announcement(|unsigned_announcement| {
                        unsigned_announcement.short_channel_id += 2;
                }, node_1_privkey, node_2_privkey, &secp_ctx);
                let valid_announcement = get_signed_channel_announcement(|unsigned_announcement| {
                        unsigned_announcement.short_channel_id += 2;
                }, node_1_privkey, node_2_privkey, &secp_ctx);
-               match net_graph_msg_handler.handle_channel_announcement(&valid_announcement) {
+               match gossip_sync.handle_channel_announcement(&valid_announcement) {
                        Ok(res) => assert!(res),
                        _ => panic!()
                };
                        Ok(res) => assert!(res),
                        _ => panic!()
                };
@@ -1907,7 +1907,7 @@ mod tests {
                // If we receive announcement for the same channel (but TX is not confirmed),
                // drop new one on the floor, since we can't see any changes.
                *chain_source.utxo_ret.lock().unwrap() = Err(chain::AccessError::UnknownTx);
                // If we receive announcement for the same channel (but TX is not confirmed),
                // drop new one on the floor, since we can't see any changes.
                *chain_source.utxo_ret.lock().unwrap() = Err(chain::AccessError::UnknownTx);
-               match net_graph_msg_handler.handle_channel_announcement(&valid_announcement) {
+               match gossip_sync.handle_channel_announcement(&valid_announcement) {
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "Channel announced without corresponding UTXO entry")
                };
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "Channel announced without corresponding UTXO entry")
                };
@@ -1918,7 +1918,7 @@ mod tests {
                        unsigned_announcement.features = ChannelFeatures::empty();
                        unsigned_announcement.short_channel_id += 2;
                }, node_1_privkey, node_2_privkey, &secp_ctx);
                        unsigned_announcement.features = ChannelFeatures::empty();
                        unsigned_announcement.short_channel_id += 2;
                }, node_1_privkey, node_2_privkey, &secp_ctx);
-               match net_graph_msg_handler.handle_channel_announcement(&valid_announcement) {
+               match gossip_sync.handle_channel_announcement(&valid_announcement) {
                        Ok(res) => assert!(res),
                        _ => panic!()
                };
                        Ok(res) => assert!(res),
                        _ => panic!()
                };
@@ -1936,20 +1936,20 @@ mod tests {
                        unsigned_announcement.short_channel_id += 3;
                        unsigned_announcement.excess_data.resize(MAX_EXCESS_BYTES_FOR_RELAY + 1, 0);
                }, node_1_privkey, node_2_privkey, &secp_ctx);
                        unsigned_announcement.short_channel_id += 3;
                        unsigned_announcement.excess_data.resize(MAX_EXCESS_BYTES_FOR_RELAY + 1, 0);
                }, node_1_privkey, node_2_privkey, &secp_ctx);
-               match net_graph_msg_handler.handle_channel_announcement(&valid_announcement) {
+               match gossip_sync.handle_channel_announcement(&valid_announcement) {
                        Ok(res) => assert!(!res),
                        _ => panic!()
                };
 
                let mut invalid_sig_announcement = valid_announcement.clone();
                invalid_sig_announcement.contents.excess_data = Vec::new();
                        Ok(res) => assert!(!res),
                        _ => panic!()
                };
 
                let mut invalid_sig_announcement = valid_announcement.clone();
                invalid_sig_announcement.contents.excess_data = Vec::new();
-               match net_graph_msg_handler.handle_channel_announcement(&invalid_sig_announcement) {
+               match gossip_sync.handle_channel_announcement(&invalid_sig_announcement) {
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "Invalid signature on channel_announcement message")
                };
 
                let channel_to_itself_announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_1_privkey, &secp_ctx);
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "Invalid signature on channel_announcement message")
                };
 
                let channel_to_itself_announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_1_privkey, &secp_ctx);
-               match net_graph_msg_handler.handle_channel_announcement(&channel_to_itself_announcement) {
+               match gossip_sync.handle_channel_announcement(&channel_to_itself_announcement) {
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "Channel announcement node had a channel with itself")
                };
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "Channel announcement node had a channel with itself")
                };
@@ -1961,7 +1961,7 @@ mod tests {
                let logger: Arc<Logger> = Arc::new(test_utils::TestLogger::new());
                let chain_source = Arc::new(test_utils::TestChainSource::new(Network::Testnet));
                let network_graph = NetworkGraph::new(genesis_block(Network::Testnet).header.block_hash());
                let logger: Arc<Logger> = Arc::new(test_utils::TestLogger::new());
                let chain_source = Arc::new(test_utils::TestChainSource::new(Network::Testnet));
                let network_graph = NetworkGraph::new(genesis_block(Network::Testnet).header.block_hash());
-               let net_graph_msg_handler = NetGraphMsgHandler::new(&network_graph, Some(chain_source.clone()), Arc::clone(&logger));
+               let gossip_sync = P2PGossipSync::new(&network_graph, Some(chain_source.clone()), Arc::clone(&logger));
 
                let node_1_privkey = &SecretKey::from_slice(&[42; 32]).unwrap();
                let node_2_privkey = &SecretKey::from_slice(&[41; 32]).unwrap();
 
                let node_1_privkey = &SecretKey::from_slice(&[42; 32]).unwrap();
                let node_2_privkey = &SecretKey::from_slice(&[41; 32]).unwrap();
@@ -1976,7 +1976,7 @@ mod tests {
 
                        let valid_channel_announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_2_privkey, &secp_ctx);
                        short_channel_id = valid_channel_announcement.contents.short_channel_id;
 
                        let valid_channel_announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_2_privkey, &secp_ctx);
                        short_channel_id = valid_channel_announcement.contents.short_channel_id;
-                       match net_graph_msg_handler.handle_channel_announcement(&valid_channel_announcement) {
+                       match gossip_sync.handle_channel_announcement(&valid_channel_announcement) {
                                Ok(_) => (),
                                Err(_) => panic!()
                        };
                                Ok(_) => (),
                                Err(_) => panic!()
                        };
@@ -1984,7 +1984,7 @@ mod tests {
                }
 
                let valid_channel_update = get_signed_channel_update(|_| {}, node_1_privkey, &secp_ctx);
                }
 
                let valid_channel_update = get_signed_channel_update(|_| {}, node_1_privkey, &secp_ctx);
-               match net_graph_msg_handler.handle_channel_update(&valid_channel_update) {
+               match gossip_sync.handle_channel_update(&valid_channel_update) {
                        Ok(res) => assert!(res),
                        _ => panic!()
                };
                        Ok(res) => assert!(res),
                        _ => panic!()
                };
@@ -2004,7 +2004,7 @@ mod tests {
                        unsigned_channel_update.excess_data.resize(MAX_EXCESS_BYTES_FOR_RELAY + 1, 0);
                }, node_1_privkey, &secp_ctx);
                // Return false because contains excess data
                        unsigned_channel_update.excess_data.resize(MAX_EXCESS_BYTES_FOR_RELAY + 1, 0);
                }, node_1_privkey, &secp_ctx);
                // Return false because contains excess data
-               match net_graph_msg_handler.handle_channel_update(&valid_channel_update) {
+               match gossip_sync.handle_channel_update(&valid_channel_update) {
                        Ok(res) => assert!(!res),
                        _ => panic!()
                };
                        Ok(res) => assert!(!res),
                        _ => panic!()
                };
@@ -2013,7 +2013,7 @@ mod tests {
                        unsigned_channel_update.timestamp += 110;
                        unsigned_channel_update.short_channel_id += 1;
                }, node_1_privkey, &secp_ctx);
                        unsigned_channel_update.timestamp += 110;
                        unsigned_channel_update.short_channel_id += 1;
                }, node_1_privkey, &secp_ctx);
-               match net_graph_msg_handler.handle_channel_update(&valid_channel_update) {
+               match gossip_sync.handle_channel_update(&valid_channel_update) {
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "Couldn't find channel for update")
                };
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "Couldn't find channel for update")
                };
@@ -2022,7 +2022,7 @@ mod tests {
                        unsigned_channel_update.htlc_maximum_msat = OptionalField::Present(MAX_VALUE_MSAT + 1);
                        unsigned_channel_update.timestamp += 110;
                }, node_1_privkey, &secp_ctx);
                        unsigned_channel_update.htlc_maximum_msat = OptionalField::Present(MAX_VALUE_MSAT + 1);
                        unsigned_channel_update.timestamp += 110;
                }, node_1_privkey, &secp_ctx);
-               match net_graph_msg_handler.handle_channel_update(&valid_channel_update) {
+               match gossip_sync.handle_channel_update(&valid_channel_update) {
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "htlc_maximum_msat is larger than maximum possible msats")
                };
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "htlc_maximum_msat is larger than maximum possible msats")
                };
@@ -2031,7 +2031,7 @@ mod tests {
                        unsigned_channel_update.htlc_maximum_msat = OptionalField::Present(amount_sats * 1000 + 1);
                        unsigned_channel_update.timestamp += 110;
                }, node_1_privkey, &secp_ctx);
                        unsigned_channel_update.htlc_maximum_msat = OptionalField::Present(amount_sats * 1000 + 1);
                        unsigned_channel_update.timestamp += 110;
                }, node_1_privkey, &secp_ctx);
-               match net_graph_msg_handler.handle_channel_update(&valid_channel_update) {
+               match gossip_sync.handle_channel_update(&valid_channel_update) {
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "htlc_maximum_msat is larger than channel capacity or capacity is bogus")
                };
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "htlc_maximum_msat is larger than channel capacity or capacity is bogus")
                };
@@ -2041,7 +2041,7 @@ mod tests {
                let valid_channel_update = get_signed_channel_update(|unsigned_channel_update| {
                        unsigned_channel_update.timestamp += 100;
                }, node_1_privkey, &secp_ctx);
                let valid_channel_update = get_signed_channel_update(|unsigned_channel_update| {
                        unsigned_channel_update.timestamp += 100;
                }, node_1_privkey, &secp_ctx);
-               match net_graph_msg_handler.handle_channel_update(&valid_channel_update) {
+               match gossip_sync.handle_channel_update(&valid_channel_update) {
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "Update had same timestamp as last processed update")
                };
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "Update had same timestamp as last processed update")
                };
@@ -2052,7 +2052,7 @@ mod tests {
                let zero_hash = Sha256dHash::hash(&[0; 32]);
                let fake_msghash = hash_to_message!(&zero_hash);
                invalid_sig_channel_update.signature = secp_ctx.sign_ecdsa(&fake_msghash, node_1_privkey);
                let zero_hash = Sha256dHash::hash(&[0; 32]);
                let fake_msghash = hash_to_message!(&zero_hash);
                invalid_sig_channel_update.signature = secp_ctx.sign_ecdsa(&fake_msghash, node_1_privkey);
-               match net_graph_msg_handler.handle_channel_update(&invalid_sig_channel_update) {
+               match gossip_sync.handle_channel_update(&invalid_sig_channel_update) {
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "Invalid signature on channel_update message")
                };
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "Invalid signature on channel_update message")
                };
@@ -2064,7 +2064,7 @@ mod tests {
                let chain_source = Arc::new(test_utils::TestChainSource::new(Network::Testnet));
                let genesis_hash = genesis_block(Network::Testnet).header.block_hash();
                let network_graph = NetworkGraph::new(genesis_hash);
                let chain_source = Arc::new(test_utils::TestChainSource::new(Network::Testnet));
                let genesis_hash = genesis_block(Network::Testnet).header.block_hash();
                let network_graph = NetworkGraph::new(genesis_hash);
-               let net_graph_msg_handler = NetGraphMsgHandler::new(&network_graph, Some(chain_source.clone()), &logger);
+               let gossip_sync = P2PGossipSync::new(&network_graph, Some(chain_source.clone()), &logger);
                let secp_ctx = Secp256k1::new();
 
                let node_1_privkey = &SecretKey::from_slice(&[42; 32]).unwrap();
                let secp_ctx = Secp256k1::new();
 
                let node_1_privkey = &SecretKey::from_slice(&[42; 32]).unwrap();
@@ -2087,7 +2087,7 @@ mod tests {
                        let valid_channel_update = get_signed_channel_update(|_| {}, node_1_privkey, &secp_ctx);
                        assert!(network_graph.read_only().channels().get(&short_channel_id).unwrap().one_to_two.is_none());
 
                        let valid_channel_update = get_signed_channel_update(|_| {}, node_1_privkey, &secp_ctx);
                        assert!(network_graph.read_only().channels().get(&short_channel_id).unwrap().one_to_two.is_none());
 
-                       net_graph_msg_handler.handle_event(&Event::PaymentPathFailed {
+                       gossip_sync.handle_event(&Event::PaymentPathFailed {
                                payment_id: None,
                                payment_hash: PaymentHash([0; 32]),
                                rejected_by_dest: false,
                                payment_id: None,
                                payment_hash: PaymentHash([0; 32]),
                                rejected_by_dest: false,
@@ -2114,7 +2114,7 @@ mod tests {
                                }
                        };
 
                                }
                        };
 
-                       net_graph_msg_handler.handle_event(&Event::PaymentPathFailed {
+                       gossip_sync.handle_event(&Event::PaymentPathFailed {
                                payment_id: None,
                                payment_hash: PaymentHash([0; 32]),
                                rejected_by_dest: false,
                                payment_id: None,
                                payment_hash: PaymentHash([0; 32]),
                                rejected_by_dest: false,
@@ -2139,7 +2139,7 @@ mod tests {
                }
 
                // Permanent closing deletes a channel
                }
 
                // Permanent closing deletes a channel
-               net_graph_msg_handler.handle_event(&Event::PaymentPathFailed {
+               gossip_sync.handle_event(&Event::PaymentPathFailed {
                        payment_id: None,
                        payment_hash: PaymentHash([0; 32]),
                        rejected_by_dest: false,
                        payment_id: None,
                        payment_hash: PaymentHash([0; 32]),
                        rejected_by_dest: false,
@@ -2168,7 +2168,7 @@ mod tests {
                let chain_source = Arc::new(test_utils::TestChainSource::new(Network::Testnet));
                let genesis_hash = genesis_block(Network::Testnet).header.block_hash();
                let network_graph = NetworkGraph::new(genesis_hash);
                let chain_source = Arc::new(test_utils::TestChainSource::new(Network::Testnet));
                let genesis_hash = genesis_block(Network::Testnet).header.block_hash();
                let network_graph = NetworkGraph::new(genesis_hash);
-               let net_graph_msg_handler = NetGraphMsgHandler::new(&network_graph, Some(chain_source.clone()), &logger);
+               let gossip_sync = P2PGossipSync::new(&network_graph, Some(chain_source.clone()), &logger);
                let secp_ctx = Secp256k1::new();
 
                let node_1_privkey = &SecretKey::from_slice(&[42; 32]).unwrap();
                let secp_ctx = Secp256k1::new();
 
                let node_1_privkey = &SecretKey::from_slice(&[42; 32]).unwrap();
@@ -2181,7 +2181,7 @@ mod tests {
                assert!(network_graph.read_only().channels().get(&short_channel_id).is_some());
 
                let valid_channel_update = get_signed_channel_update(|_| {}, node_1_privkey, &secp_ctx);
                assert!(network_graph.read_only().channels().get(&short_channel_id).is_some());
 
                let valid_channel_update = get_signed_channel_update(|_| {}, node_1_privkey, &secp_ctx);
-               assert!(net_graph_msg_handler.handle_channel_update(&valid_channel_update).is_ok());
+               assert!(gossip_sync.handle_channel_update(&valid_channel_update).is_ok());
                assert!(network_graph.read_only().channels().get(&short_channel_id).unwrap().one_to_two.is_some());
 
                network_graph.remove_stale_channels_with_time(100 + STALE_CHANNEL_UPDATE_AGE_LIMIT_SECS);
                assert!(network_graph.read_only().channels().get(&short_channel_id).unwrap().one_to_two.is_some());
 
                network_graph.remove_stale_channels_with_time(100 + STALE_CHANNEL_UPDATE_AGE_LIMIT_SECS);
@@ -2211,12 +2211,12 @@ mod tests {
        #[test]
        fn getting_next_channel_announcements() {
                let network_graph = create_network_graph();
        #[test]
        fn getting_next_channel_announcements() {
                let network_graph = create_network_graph();
-               let (secp_ctx, net_graph_msg_handler) = create_net_graph_msg_handler(&network_graph);
+               let (secp_ctx, gossip_sync) = create_gossip_sync(&network_graph);
                let node_1_privkey = &SecretKey::from_slice(&[42; 32]).unwrap();
                let node_2_privkey = &SecretKey::from_slice(&[41; 32]).unwrap();
 
                // Channels were not announced yet.
                let node_1_privkey = &SecretKey::from_slice(&[42; 32]).unwrap();
                let node_2_privkey = &SecretKey::from_slice(&[41; 32]).unwrap();
 
                // Channels were not announced yet.
-               let channels_with_announcements = net_graph_msg_handler.get_next_channel_announcements(0, 1);
+               let channels_with_announcements = gossip_sync.get_next_channel_announcements(0, 1);
                assert_eq!(channels_with_announcements.len(), 0);
 
                let short_channel_id;
                assert_eq!(channels_with_announcements.len(), 0);
 
                let short_channel_id;
@@ -2224,14 +2224,14 @@ mod tests {
                        // Announce a channel we will update
                        let valid_channel_announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_2_privkey, &secp_ctx);
                        short_channel_id = valid_channel_announcement.contents.short_channel_id;
                        // Announce a channel we will update
                        let valid_channel_announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_2_privkey, &secp_ctx);
                        short_channel_id = valid_channel_announcement.contents.short_channel_id;
-                       match net_graph_msg_handler.handle_channel_announcement(&valid_channel_announcement) {
+                       match gossip_sync.handle_channel_announcement(&valid_channel_announcement) {
                                Ok(_) => (),
                                Err(_) => panic!()
                        };
                }
 
                // Contains initial channel announcement now.
                                Ok(_) => (),
                                Err(_) => panic!()
                        };
                }
 
                // Contains initial channel announcement now.
-               let channels_with_announcements = net_graph_msg_handler.get_next_channel_announcements(short_channel_id, 1);
+               let channels_with_announcements = gossip_sync.get_next_channel_announcements(short_channel_id, 1);
                assert_eq!(channels_with_announcements.len(), 1);
                if let Some(channel_announcements) = channels_with_announcements.first() {
                        let &(_, ref update_1, ref update_2) = channel_announcements;
                assert_eq!(channels_with_announcements.len(), 1);
                if let Some(channel_announcements) = channels_with_announcements.first() {
                        let &(_, ref update_1, ref update_2) = channel_announcements;
@@ -2247,14 +2247,14 @@ mod tests {
                        let valid_channel_update = get_signed_channel_update(|unsigned_channel_update| {
                                unsigned_channel_update.timestamp = 101;
                        }, node_1_privkey, &secp_ctx);
                        let valid_channel_update = get_signed_channel_update(|unsigned_channel_update| {
                                unsigned_channel_update.timestamp = 101;
                        }, node_1_privkey, &secp_ctx);
-                       match net_graph_msg_handler.handle_channel_update(&valid_channel_update) {
+                       match gossip_sync.handle_channel_update(&valid_channel_update) {
                                Ok(_) => (),
                                Err(_) => panic!()
                        };
                }
 
                // Now contains an initial announcement and an update.
                                Ok(_) => (),
                                Err(_) => panic!()
                        };
                }
 
                // Now contains an initial announcement and an update.
-               let channels_with_announcements = net_graph_msg_handler.get_next_channel_announcements(short_channel_id, 1);
+               let channels_with_announcements = gossip_sync.get_next_channel_announcements(short_channel_id, 1);
                assert_eq!(channels_with_announcements.len(), 1);
                if let Some(channel_announcements) = channels_with_announcements.first() {
                        let &(_, ref update_1, ref update_2) = channel_announcements;
                assert_eq!(channels_with_announcements.len(), 1);
                if let Some(channel_announcements) = channels_with_announcements.first() {
                        let &(_, ref update_1, ref update_2) = channel_announcements;
@@ -2270,14 +2270,14 @@ mod tests {
                                unsigned_channel_update.timestamp = 102;
                                unsigned_channel_update.excess_data = [1; MAX_EXCESS_BYTES_FOR_RELAY + 1].to_vec();
                        }, node_1_privkey, &secp_ctx);
                                unsigned_channel_update.timestamp = 102;
                                unsigned_channel_update.excess_data = [1; MAX_EXCESS_BYTES_FOR_RELAY + 1].to_vec();
                        }, node_1_privkey, &secp_ctx);
-                       match net_graph_msg_handler.handle_channel_update(&valid_channel_update) {
+                       match gossip_sync.handle_channel_update(&valid_channel_update) {
                                Ok(_) => (),
                                Err(_) => panic!()
                        };
                }
 
                // Test that announcements with excess data won't be returned
                                Ok(_) => (),
                                Err(_) => panic!()
                        };
                }
 
                // Test that announcements with excess data won't be returned
-               let channels_with_announcements = net_graph_msg_handler.get_next_channel_announcements(short_channel_id, 1);
+               let channels_with_announcements = gossip_sync.get_next_channel_announcements(short_channel_id, 1);
                assert_eq!(channels_with_announcements.len(), 1);
                if let Some(channel_announcements) = channels_with_announcements.first() {
                        let &(_, ref update_1, ref update_2) = channel_announcements;
                assert_eq!(channels_with_announcements.len(), 1);
                if let Some(channel_announcements) = channels_with_announcements.first() {
                        let &(_, ref update_1, ref update_2) = channel_announcements;
@@ -2288,26 +2288,26 @@ mod tests {
                }
 
                // Further starting point have no channels after it
                }
 
                // Further starting point have no channels after it
-               let channels_with_announcements = net_graph_msg_handler.get_next_channel_announcements(short_channel_id + 1000, 1);
+               let channels_with_announcements = gossip_sync.get_next_channel_announcements(short_channel_id + 1000, 1);
                assert_eq!(channels_with_announcements.len(), 0);
        }
 
        #[test]
        fn getting_next_node_announcements() {
                let network_graph = create_network_graph();
                assert_eq!(channels_with_announcements.len(), 0);
        }
 
        #[test]
        fn getting_next_node_announcements() {
                let network_graph = create_network_graph();
-               let (secp_ctx, net_graph_msg_handler) = create_net_graph_msg_handler(&network_graph);
+               let (secp_ctx, gossip_sync) = create_gossip_sync(&network_graph);
                let node_1_privkey = &SecretKey::from_slice(&[42; 32]).unwrap();
                let node_2_privkey = &SecretKey::from_slice(&[41; 32]).unwrap();
                let node_id_1 = PublicKey::from_secret_key(&secp_ctx, node_1_privkey);
 
                // No nodes yet.
                let node_1_privkey = &SecretKey::from_slice(&[42; 32]).unwrap();
                let node_2_privkey = &SecretKey::from_slice(&[41; 32]).unwrap();
                let node_id_1 = PublicKey::from_secret_key(&secp_ctx, node_1_privkey);
 
                // No nodes yet.
-               let next_announcements = net_graph_msg_handler.get_next_node_announcements(None, 10);
+               let next_announcements = gossip_sync.get_next_node_announcements(None, 10);
                assert_eq!(next_announcements.len(), 0);
 
                {
                        // Announce a channel to add 2 nodes
                        let valid_channel_announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_2_privkey, &secp_ctx);
                assert_eq!(next_announcements.len(), 0);
 
                {
                        // Announce a channel to add 2 nodes
                        let valid_channel_announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_2_privkey, &secp_ctx);
-                       match net_graph_msg_handler.handle_channel_announcement(&valid_channel_announcement) {
+                       match gossip_sync.handle_channel_announcement(&valid_channel_announcement) {
                                Ok(_) => (),
                                Err(_) => panic!()
                        };
                                Ok(_) => (),
                                Err(_) => panic!()
                        };
@@ -2315,28 +2315,28 @@ mod tests {
 
 
                // Nodes were never announced
 
 
                // Nodes were never announced
-               let next_announcements = net_graph_msg_handler.get_next_node_announcements(None, 3);
+               let next_announcements = gossip_sync.get_next_node_announcements(None, 3);
                assert_eq!(next_announcements.len(), 0);
 
                {
                        let valid_announcement = get_signed_node_announcement(|_| {}, node_1_privkey, &secp_ctx);
                assert_eq!(next_announcements.len(), 0);
 
                {
                        let valid_announcement = get_signed_node_announcement(|_| {}, node_1_privkey, &secp_ctx);
-                       match net_graph_msg_handler.handle_node_announcement(&valid_announcement) {
+                       match gossip_sync.handle_node_announcement(&valid_announcement) {
                                Ok(_) => (),
                                Err(_) => panic!()
                        };
 
                        let valid_announcement = get_signed_node_announcement(|_| {}, node_2_privkey, &secp_ctx);
                                Ok(_) => (),
                                Err(_) => panic!()
                        };
 
                        let valid_announcement = get_signed_node_announcement(|_| {}, node_2_privkey, &secp_ctx);
-                       match net_graph_msg_handler.handle_node_announcement(&valid_announcement) {
+                       match gossip_sync.handle_node_announcement(&valid_announcement) {
                                Ok(_) => (),
                                Err(_) => panic!()
                        };
                }
 
                                Ok(_) => (),
                                Err(_) => panic!()
                        };
                }
 
-               let next_announcements = net_graph_msg_handler.get_next_node_announcements(None, 3);
+               let next_announcements = gossip_sync.get_next_node_announcements(None, 3);
                assert_eq!(next_announcements.len(), 2);
 
                // Skip the first node.
                assert_eq!(next_announcements.len(), 2);
 
                // Skip the first node.
-               let next_announcements = net_graph_msg_handler.get_next_node_announcements(Some(&node_id_1), 2);
+               let next_announcements = gossip_sync.get_next_node_announcements(Some(&node_id_1), 2);
                assert_eq!(next_announcements.len(), 1);
 
                {
                assert_eq!(next_announcements.len(), 1);
 
                {
@@ -2345,33 +2345,33 @@ mod tests {
                                unsigned_announcement.timestamp += 10;
                                unsigned_announcement.excess_data = [1; MAX_EXCESS_BYTES_FOR_RELAY + 1].to_vec();
                        }, node_2_privkey, &secp_ctx);
                                unsigned_announcement.timestamp += 10;
                                unsigned_announcement.excess_data = [1; MAX_EXCESS_BYTES_FOR_RELAY + 1].to_vec();
                        }, node_2_privkey, &secp_ctx);
-                       match net_graph_msg_handler.handle_node_announcement(&valid_announcement) {
+                       match gossip_sync.handle_node_announcement(&valid_announcement) {
                                Ok(res) => assert!(!res),
                                Err(_) => panic!()
                        };
                }
 
                                Ok(res) => assert!(!res),
                                Err(_) => panic!()
                        };
                }
 
-               let next_announcements = net_graph_msg_handler.get_next_node_announcements(Some(&node_id_1), 2);
+               let next_announcements = gossip_sync.get_next_node_announcements(Some(&node_id_1), 2);
                assert_eq!(next_announcements.len(), 0);
        }
 
        #[test]
        fn network_graph_serialization() {
                let network_graph = create_network_graph();
                assert_eq!(next_announcements.len(), 0);
        }
 
        #[test]
        fn network_graph_serialization() {
                let network_graph = create_network_graph();
-               let (secp_ctx, net_graph_msg_handler) = create_net_graph_msg_handler(&network_graph);
+               let (secp_ctx, gossip_sync) = create_gossip_sync(&network_graph);
 
                let node_1_privkey = &SecretKey::from_slice(&[42; 32]).unwrap();
                let node_2_privkey = &SecretKey::from_slice(&[41; 32]).unwrap();
 
                // Announce a channel to add a corresponding node.
                let valid_announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_2_privkey, &secp_ctx);
 
                let node_1_privkey = &SecretKey::from_slice(&[42; 32]).unwrap();
                let node_2_privkey = &SecretKey::from_slice(&[41; 32]).unwrap();
 
                // Announce a channel to add a corresponding node.
                let valid_announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_2_privkey, &secp_ctx);
-               match net_graph_msg_handler.handle_channel_announcement(&valid_announcement) {
+               match gossip_sync.handle_channel_announcement(&valid_announcement) {
                        Ok(res) => assert!(res),
                        _ => panic!()
                };
 
                let valid_announcement = get_signed_node_announcement(|_| {}, node_1_privkey, &secp_ctx);
                        Ok(res) => assert!(res),
                        _ => panic!()
                };
 
                let valid_announcement = get_signed_node_announcement(|_| {}, node_1_privkey, &secp_ctx);
-               match net_graph_msg_handler.handle_node_announcement(&valid_announcement) {
+               match gossip_sync.handle_node_announcement(&valid_announcement) {
                        Ok(_) => (),
                        Err(_) => panic!()
                };
                        Ok(_) => (),
                        Err(_) => panic!()
                };
@@ -2401,7 +2401,7 @@ mod tests {
                use std::time::{SystemTime, UNIX_EPOCH};
 
                let network_graph = create_network_graph();
                use std::time::{SystemTime, UNIX_EPOCH};
 
                let network_graph = create_network_graph();
-               let (secp_ctx, net_graph_msg_handler) = create_net_graph_msg_handler(&network_graph);
+               let (secp_ctx, gossip_sync) = create_gossip_sync(&network_graph);
                let node_privkey_1 = &SecretKey::from_slice(&[42; 32]).unwrap();
                let node_id_1 = PublicKey::from_secret_key(&secp_ctx, node_privkey_1);
 
                let node_privkey_1 = &SecretKey::from_slice(&[42; 32]).unwrap();
                let node_id_1 = PublicKey::from_secret_key(&secp_ctx, node_privkey_1);
 
@@ -2410,16 +2410,16 @@ mod tests {
                // It should ignore if gossip_queries feature is not enabled
                {
                        let init_msg = Init { features: InitFeatures::known().clear_gossip_queries(), remote_network_address: None };
                // It should ignore if gossip_queries feature is not enabled
                {
                        let init_msg = Init { features: InitFeatures::known().clear_gossip_queries(), remote_network_address: None };
-                       net_graph_msg_handler.peer_connected(&node_id_1, &init_msg);
-                       let events = net_graph_msg_handler.get_and_clear_pending_msg_events();
+                       gossip_sync.peer_connected(&node_id_1, &init_msg);
+                       let events = gossip_sync.get_and_clear_pending_msg_events();
                        assert_eq!(events.len(), 0);
                }
 
                // It should send a gossip_timestamp_filter with the correct information
                {
                        let init_msg = Init { features: InitFeatures::known(), remote_network_address: None };
                        assert_eq!(events.len(), 0);
                }
 
                // It should send a gossip_timestamp_filter with the correct information
                {
                        let init_msg = Init { features: InitFeatures::known(), remote_network_address: None };
-                       net_graph_msg_handler.peer_connected(&node_id_1, &init_msg);
-                       let events = net_graph_msg_handler.get_and_clear_pending_msg_events();
+                       gossip_sync.peer_connected(&node_id_1, &init_msg);
+                       let events = gossip_sync.get_and_clear_pending_msg_events();
                        assert_eq!(events.len(), 1);
                        match &events[0] {
                                MessageSendEvent::SendGossipTimestampFilter{ node_id, msg } => {
                        assert_eq!(events.len(), 1);
                        match &events[0] {
                                MessageSendEvent::SendGossipTimestampFilter{ node_id, msg } => {
@@ -2438,7 +2438,7 @@ mod tests {
        #[test]
        fn handling_query_channel_range() {
                let network_graph = create_network_graph();
        #[test]
        fn handling_query_channel_range() {
                let network_graph = create_network_graph();
-               let (secp_ctx, net_graph_msg_handler) = create_net_graph_msg_handler(&network_graph);
+               let (secp_ctx, gossip_sync) = create_gossip_sync(&network_graph);
 
                let chain_hash = genesis_block(Network::Testnet).header.block_hash();
                let node_1_privkey = &SecretKey::from_slice(&[42; 32]).unwrap();
 
                let chain_hash = genesis_block(Network::Testnet).header.block_hash();
                let node_1_privkey = &SecretKey::from_slice(&[42; 32]).unwrap();
@@ -2462,7 +2462,7 @@ mod tests {
                        let valid_announcement = get_signed_channel_announcement(|unsigned_announcement| {
                                unsigned_announcement.short_channel_id = scid;
                        }, node_1_privkey, node_2_privkey, &secp_ctx);
                        let valid_announcement = get_signed_channel_announcement(|unsigned_announcement| {
                                unsigned_announcement.short_channel_id = scid;
                        }, node_1_privkey, node_2_privkey, &secp_ctx);
-                       match net_graph_msg_handler.handle_channel_announcement(&valid_announcement) {
+                       match gossip_sync.handle_channel_announcement(&valid_announcement) {
                                Ok(_) => (),
                                _ => panic!()
                        };
                                Ok(_) => (),
                                _ => panic!()
                        };
@@ -2470,7 +2470,7 @@ mod tests {
 
                // Error when number_of_blocks=0
                do_handling_query_channel_range(
 
                // Error when number_of_blocks=0
                do_handling_query_channel_range(
-                       &net_graph_msg_handler,
+                       &gossip_sync,
                        &node_id_2,
                        QueryChannelRange {
                                chain_hash: chain_hash.clone(),
                        &node_id_2,
                        QueryChannelRange {
                                chain_hash: chain_hash.clone(),
@@ -2489,7 +2489,7 @@ mod tests {
 
                // Error when wrong chain
                do_handling_query_channel_range(
 
                // Error when wrong chain
                do_handling_query_channel_range(
-                       &net_graph_msg_handler,
+                       &gossip_sync,
                        &node_id_2,
                        QueryChannelRange {
                                chain_hash: genesis_block(Network::Bitcoin).header.block_hash(),
                        &node_id_2,
                        QueryChannelRange {
                                chain_hash: genesis_block(Network::Bitcoin).header.block_hash(),
@@ -2508,7 +2508,7 @@ mod tests {
 
                // Error when first_blocknum > 0xffffff
                do_handling_query_channel_range(
 
                // Error when first_blocknum > 0xffffff
                do_handling_query_channel_range(
-                       &net_graph_msg_handler,
+                       &gossip_sync,
                        &node_id_2,
                        QueryChannelRange {
                                chain_hash: chain_hash.clone(),
                        &node_id_2,
                        QueryChannelRange {
                                chain_hash: chain_hash.clone(),
@@ -2527,7 +2527,7 @@ mod tests {
 
                // Empty reply when max valid SCID block num
                do_handling_query_channel_range(
 
                // Empty reply when max valid SCID block num
                do_handling_query_channel_range(
-                       &net_graph_msg_handler,
+                       &gossip_sync,
                        &node_id_2,
                        QueryChannelRange {
                                chain_hash: chain_hash.clone(),
                        &node_id_2,
                        QueryChannelRange {
                                chain_hash: chain_hash.clone(),
@@ -2548,7 +2548,7 @@ mod tests {
 
                // No results in valid query range
                do_handling_query_channel_range(
 
                // No results in valid query range
                do_handling_query_channel_range(
-                       &net_graph_msg_handler,
+                       &gossip_sync,
                        &node_id_2,
                        QueryChannelRange {
                                chain_hash: chain_hash.clone(),
                        &node_id_2,
                        QueryChannelRange {
                                chain_hash: chain_hash.clone(),
@@ -2569,7 +2569,7 @@ mod tests {
 
                // Overflow first_blocknum + number_of_blocks
                do_handling_query_channel_range(
 
                // Overflow first_blocknum + number_of_blocks
                do_handling_query_channel_range(
-                       &net_graph_msg_handler,
+                       &gossip_sync,
                        &node_id_2,
                        QueryChannelRange {
                                chain_hash: chain_hash.clone(),
                        &node_id_2,
                        QueryChannelRange {
                                chain_hash: chain_hash.clone(),
@@ -2592,7 +2592,7 @@ mod tests {
 
                // Single block exactly full
                do_handling_query_channel_range(
 
                // Single block exactly full
                do_handling_query_channel_range(
-                       &net_graph_msg_handler,
+                       &gossip_sync,
                        &node_id_2,
                        QueryChannelRange {
                                chain_hash: chain_hash.clone(),
                        &node_id_2,
                        QueryChannelRange {
                                chain_hash: chain_hash.clone(),
@@ -2615,7 +2615,7 @@ mod tests {
 
                // Multiple split on new block
                do_handling_query_channel_range(
 
                // Multiple split on new block
                do_handling_query_channel_range(
-                       &net_graph_msg_handler,
+                       &gossip_sync,
                        &node_id_2,
                        QueryChannelRange {
                                chain_hash: chain_hash.clone(),
                        &node_id_2,
                        QueryChannelRange {
                                chain_hash: chain_hash.clone(),
@@ -2647,7 +2647,7 @@ mod tests {
 
                // Multiple split on same block
                do_handling_query_channel_range(
 
                // Multiple split on same block
                do_handling_query_channel_range(
-                       &net_graph_msg_handler,
+                       &gossip_sync,
                        &node_id_2,
                        QueryChannelRange {
                                chain_hash: chain_hash.clone(),
                        &node_id_2,
                        QueryChannelRange {
                                chain_hash: chain_hash.clone(),
@@ -2679,7 +2679,7 @@ mod tests {
        }
 
        fn do_handling_query_channel_range(
        }
 
        fn do_handling_query_channel_range(
-               net_graph_msg_handler: &NetGraphMsgHandler<&NetworkGraph, Arc<test_utils::TestChainSource>, Arc<test_utils::TestLogger>>,
+               gossip_sync: &P2PGossipSync<&NetworkGraph, Arc<test_utils::TestChainSource>, Arc<test_utils::TestLogger>>,
                test_node_id: &PublicKey,
                msg: QueryChannelRange,
                expected_ok: bool,
                test_node_id: &PublicKey,
                msg: QueryChannelRange,
                expected_ok: bool,
@@ -2688,7 +2688,7 @@ mod tests {
                let mut max_firstblocknum = msg.first_blocknum.saturating_sub(1);
                let mut c_lightning_0_9_prev_end_blocknum = max_firstblocknum;
                let query_end_blocknum = msg.end_blocknum();
                let mut max_firstblocknum = msg.first_blocknum.saturating_sub(1);
                let mut c_lightning_0_9_prev_end_blocknum = max_firstblocknum;
                let query_end_blocknum = msg.end_blocknum();
-               let result = net_graph_msg_handler.handle_query_channel_range(test_node_id, msg);
+               let result = gossip_sync.handle_query_channel_range(test_node_id, msg);
 
                if expected_ok {
                        assert!(result.is_ok());
 
                if expected_ok {
                        assert!(result.is_ok());
@@ -2696,7 +2696,7 @@ mod tests {
                        assert!(result.is_err());
                }
 
                        assert!(result.is_err());
                }
 
-               let events = net_graph_msg_handler.get_and_clear_pending_msg_events();
+               let events = gossip_sync.get_and_clear_pending_msg_events();
                assert_eq!(events.len(), expected_replies.len());
 
                for i in 0..events.len() {
                assert_eq!(events.len(), expected_replies.len());
 
                for i in 0..events.len() {
@@ -2729,13 +2729,13 @@ mod tests {
        #[test]
        fn handling_query_short_channel_ids() {
                let network_graph = create_network_graph();
        #[test]
        fn handling_query_short_channel_ids() {
                let network_graph = create_network_graph();
-               let (secp_ctx, net_graph_msg_handler) = create_net_graph_msg_handler(&network_graph);
+               let (secp_ctx, gossip_sync) = create_gossip_sync(&network_graph);
                let node_privkey = &SecretKey::from_slice(&[41; 32]).unwrap();
                let node_id = PublicKey::from_secret_key(&secp_ctx, node_privkey);
 
                let chain_hash = genesis_block(Network::Testnet).header.block_hash();
 
                let node_privkey = &SecretKey::from_slice(&[41; 32]).unwrap();
                let node_id = PublicKey::from_secret_key(&secp_ctx, node_privkey);
 
                let chain_hash = genesis_block(Network::Testnet).header.block_hash();
 
-               let result = net_graph_msg_handler.handle_query_short_channel_ids(&node_id, QueryShortChannelIds {
+               let result = gossip_sync.handle_query_short_channel_ids(&node_id, QueryShortChannelIds {
                        chain_hash,
                        short_channel_ids: vec![0x0003e8_000000_0000],
                });
                        chain_hash,
                        short_channel_ids: vec![0x0003e8_000000_0000],
                });
index 5d4d4ac123818ca0cda313a4e768a4b479f8ff3d..9bf48501c2dd018a9247cf21be10c4c4b5bdd11d 100644 (file)
@@ -9,7 +9,7 @@
 
 //! The top-level routing/network map tracking logic lives here.
 //!
 
 //! The top-level routing/network map tracking logic lives here.
 //!
-//! You probably want to create a NetGraphMsgHandler and use that as your RoutingMessageHandler and then
+//! You probably want to create a P2PGossipSync and use that as your RoutingMessageHandler and then
 //! interrogate it to get routes for your own payments.
 
 use bitcoin::secp256k1::PublicKey;
 //! interrogate it to get routes for your own payments.
 
 use bitcoin::secp256k1::PublicKey;
@@ -1858,7 +1858,7 @@ fn build_route_from_hops_internal<L: Deref>(
 
 #[cfg(test)]
 mod tests {
 
 #[cfg(test)]
 mod tests {
-       use routing::network_graph::{NetworkGraph, NetGraphMsgHandler, NodeId};
+       use routing::network_graph::{NetworkGraph, P2PGossipSync, NodeId};
        use routing::router::{get_route, build_route_from_hops_internal, add_random_cltv_offset, default_node_features,
                PaymentParameters, Route, RouteHint, RouteHintHop, RouteHop, RoutingFees,
                DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA, MAX_PATH_LENGTH_ESTIMATE};
        use routing::router::{get_route, build_route_from_hops_internal, add_random_cltv_offset, default_node_features,
                PaymentParameters, Route, RouteHint, RouteHintHop, RouteHop, RoutingFees,
                DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA, MAX_PATH_LENGTH_ESTIMATE};
@@ -1926,7 +1926,7 @@ mod tests {
 
        // Using the same keys for LN and BTC ids
        fn add_channel(
 
        // Using the same keys for LN and BTC ids
        fn add_channel(
-               net_graph_msg_handler: &NetGraphMsgHandler<Arc<NetworkGraph>, Arc<test_utils::TestChainSource>, Arc<test_utils::TestLogger>>,
+               gossip_sync: &P2PGossipSync<Arc<NetworkGraph>, Arc<test_utils::TestChainSource>, Arc<test_utils::TestLogger>>,
                secp_ctx: &Secp256k1<All>, node_1_privkey: &SecretKey, node_2_privkey: &SecretKey, features: ChannelFeatures, short_channel_id: u64
        ) {
                let node_id_1 = PublicKey::from_secret_key(&secp_ctx, node_1_privkey);
                secp_ctx: &Secp256k1<All>, node_1_privkey: &SecretKey, node_2_privkey: &SecretKey, features: ChannelFeatures, short_channel_id: u64
        ) {
                let node_id_1 = PublicKey::from_secret_key(&secp_ctx, node_1_privkey);
@@ -1951,14 +1951,14 @@ mod tests {
                        bitcoin_signature_2: secp_ctx.sign_ecdsa(&msghash, node_2_privkey),
                        contents: unsigned_announcement.clone(),
                };
                        bitcoin_signature_2: secp_ctx.sign_ecdsa(&msghash, node_2_privkey),
                        contents: unsigned_announcement.clone(),
                };
-               match net_graph_msg_handler.handle_channel_announcement(&valid_announcement) {
+               match gossip_sync.handle_channel_announcement(&valid_announcement) {
                        Ok(res) => assert!(res),
                        _ => panic!()
                };
        }
 
        fn update_channel(
                        Ok(res) => assert!(res),
                        _ => panic!()
                };
        }
 
        fn update_channel(
-               net_graph_msg_handler: &NetGraphMsgHandler<Arc<NetworkGraph>, Arc<test_utils::TestChainSource>, Arc<test_utils::TestLogger>>,
+               gossip_sync: &P2PGossipSync<Arc<NetworkGraph>, Arc<test_utils::TestChainSource>, Arc<test_utils::TestLogger>>,
                secp_ctx: &Secp256k1<All>, node_privkey: &SecretKey, update: UnsignedChannelUpdate
        ) {
                let msghash = hash_to_message!(&Sha256dHash::hash(&update.encode()[..])[..]);
                secp_ctx: &Secp256k1<All>, node_privkey: &SecretKey, update: UnsignedChannelUpdate
        ) {
                let msghash = hash_to_message!(&Sha256dHash::hash(&update.encode()[..])[..]);
@@ -1967,14 +1967,14 @@ mod tests {
                        contents: update.clone()
                };
 
                        contents: update.clone()
                };
 
-               match net_graph_msg_handler.handle_channel_update(&valid_channel_update) {
+               match gossip_sync.handle_channel_update(&valid_channel_update) {
                        Ok(res) => assert!(res),
                        Err(_) => panic!()
                };
        }
 
        fn add_or_update_node(
                        Ok(res) => assert!(res),
                        Err(_) => panic!()
                };
        }
 
        fn add_or_update_node(
-               net_graph_msg_handler: &NetGraphMsgHandler<Arc<NetworkGraph>, Arc<test_utils::TestChainSource>, Arc<test_utils::TestLogger>>,
+               gossip_sync: &P2PGossipSync<Arc<NetworkGraph>, Arc<test_utils::TestChainSource>, Arc<test_utils::TestLogger>>,
                secp_ctx: &Secp256k1<All>, node_privkey: &SecretKey, features: NodeFeatures, timestamp: u32
        ) {
                let node_id = PublicKey::from_secret_key(&secp_ctx, node_privkey);
                secp_ctx: &Secp256k1<All>, node_privkey: &SecretKey, features: NodeFeatures, timestamp: u32
        ) {
                let node_id = PublicKey::from_secret_key(&secp_ctx, node_privkey);
@@ -1994,7 +1994,7 @@ mod tests {
                        contents: unsigned_announcement.clone()
                };
 
                        contents: unsigned_announcement.clone()
                };
 
-               match net_graph_msg_handler.handle_node_announcement(&valid_announcement) {
+               match gossip_sync.handle_node_announcement(&valid_announcement) {
                        Ok(_) => (),
                        Err(_) => panic!()
                };
                        Ok(_) => (),
                        Err(_) => panic!()
                };
@@ -2029,7 +2029,7 @@ mod tests {
        }
 
        fn build_line_graph() -> (
        }
 
        fn build_line_graph() -> (
-               Secp256k1<All>, sync::Arc<NetworkGraph>, NetGraphMsgHandler<sync::Arc<NetworkGraph>,
+               Secp256k1<All>, sync::Arc<NetworkGraph>, P2PGossipSync<sync::Arc<NetworkGraph>,
                sync::Arc<test_utils::TestChainSource>, sync::Arc<crate::util::test_utils::TestLogger>>,
                sync::Arc<test_utils::TestChainSource>, sync::Arc<test_utils::TestLogger>,
        ) {
                sync::Arc<test_utils::TestChainSource>, sync::Arc<crate::util::test_utils::TestLogger>>,
                sync::Arc<test_utils::TestChainSource>, sync::Arc<test_utils::TestLogger>,
        ) {
@@ -2037,7 +2037,7 @@ mod tests {
                let logger = Arc::new(test_utils::TestLogger::new());
                let chain_monitor = Arc::new(test_utils::TestChainSource::new(Network::Testnet));
                let network_graph = Arc::new(NetworkGraph::new(genesis_block(Network::Testnet).header.block_hash()));
                let logger = Arc::new(test_utils::TestLogger::new());
                let chain_monitor = Arc::new(test_utils::TestChainSource::new(Network::Testnet));
                let network_graph = Arc::new(NetworkGraph::new(genesis_block(Network::Testnet).header.block_hash()));
-               let net_graph_msg_handler = NetGraphMsgHandler::new(Arc::clone(&network_graph), None, Arc::clone(&logger));
+               let gossip_sync = P2PGossipSync::new(Arc::clone(&network_graph), None, Arc::clone(&logger));
 
                // Build network from our_id to node 19:
                // our_id -1(1)2- node0 -1(2)2- node1 - ... - node19
 
                // Build network from our_id to node 19:
                // our_id -1(1)2- node0 -1(2)2- node1 - ... - node19
@@ -2046,9 +2046,9 @@ mod tests {
                for (idx, (cur_privkey, next_privkey)) in core::iter::once(&our_privkey)
                        .chain(privkeys.iter()).zip(privkeys.iter()).enumerate() {
                        let cur_short_channel_id = (idx as u64) + 1;
                for (idx, (cur_privkey, next_privkey)) in core::iter::once(&our_privkey)
                        .chain(privkeys.iter()).zip(privkeys.iter()).enumerate() {
                        let cur_short_channel_id = (idx as u64) + 1;
-                       add_channel(&net_graph_msg_handler, &secp_ctx, &cur_privkey, &next_privkey,
+                       add_channel(&gossip_sync, &secp_ctx, &cur_privkey, &next_privkey,
                                ChannelFeatures::from_le_bytes(id_to_feature_flags(1)), cur_short_channel_id);
                                ChannelFeatures::from_le_bytes(id_to_feature_flags(1)), cur_short_channel_id);
-                       update_channel(&net_graph_msg_handler, &secp_ctx, &cur_privkey, UnsignedChannelUpdate {
+                       update_channel(&gossip_sync, &secp_ctx, &cur_privkey, UnsignedChannelUpdate {
                                chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                                short_channel_id: cur_short_channel_id,
                                timestamp: idx as u32,
                                chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                                short_channel_id: cur_short_channel_id,
                                timestamp: idx as u32,
@@ -2060,7 +2060,7 @@ mod tests {
                                fee_proportional_millionths: 0,
                                excess_data: Vec::new()
                        });
                                fee_proportional_millionths: 0,
                                excess_data: Vec::new()
                        });
-                       update_channel(&net_graph_msg_handler, &secp_ctx, &next_privkey, UnsignedChannelUpdate {
+                       update_channel(&gossip_sync, &secp_ctx, &next_privkey, UnsignedChannelUpdate {
                                chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                                short_channel_id: cur_short_channel_id,
                                timestamp: (idx as u32)+1,
                                chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                                short_channel_id: cur_short_channel_id,
                                timestamp: (idx as u32)+1,
@@ -2072,17 +2072,17 @@ mod tests {
                                fee_proportional_millionths: 0,
                                excess_data: Vec::new()
                        });
                                fee_proportional_millionths: 0,
                                excess_data: Vec::new()
                        });
-                       add_or_update_node(&net_graph_msg_handler, &secp_ctx, next_privkey,
+                       add_or_update_node(&gossip_sync, &secp_ctx, next_privkey,
                                NodeFeatures::from_le_bytes(id_to_feature_flags(1)), 0);
                }
 
                                NodeFeatures::from_le_bytes(id_to_feature_flags(1)), 0);
                }
 
-               (secp_ctx, network_graph, net_graph_msg_handler, chain_monitor, logger)
+               (secp_ctx, network_graph, gossip_sync, chain_monitor, logger)
        }
 
        fn build_graph() -> (
                Secp256k1<All>,
                sync::Arc<NetworkGraph>,
        }
 
        fn build_graph() -> (
                Secp256k1<All>,
                sync::Arc<NetworkGraph>,
-               NetGraphMsgHandler<sync::Arc<NetworkGraph>, sync::Arc<test_utils::TestChainSource>, sync::Arc<crate::util::test_utils::TestLogger>>,
+               P2PGossipSync<sync::Arc<NetworkGraph>, sync::Arc<test_utils::TestChainSource>, sync::Arc<crate::util::test_utils::TestLogger>>,
                sync::Arc<test_utils::TestChainSource>,
                sync::Arc<test_utils::TestLogger>,
        ) {
                sync::Arc<test_utils::TestChainSource>,
                sync::Arc<test_utils::TestLogger>,
        ) {
@@ -2090,7 +2090,7 @@ mod tests {
                let logger = Arc::new(test_utils::TestLogger::new());
                let chain_monitor = Arc::new(test_utils::TestChainSource::new(Network::Testnet));
                let network_graph = Arc::new(NetworkGraph::new(genesis_block(Network::Testnet).header.block_hash()));
                let logger = Arc::new(test_utils::TestLogger::new());
                let chain_monitor = Arc::new(test_utils::TestChainSource::new(Network::Testnet));
                let network_graph = Arc::new(NetworkGraph::new(genesis_block(Network::Testnet).header.block_hash()));
-               let net_graph_msg_handler = NetGraphMsgHandler::new(Arc::clone(&network_graph), None, Arc::clone(&logger));
+               let gossip_sync = P2PGossipSync::new(Arc::clone(&network_graph), None, Arc::clone(&logger));
                // Build network from our_id to node6:
                //
                //        -1(1)2-  node0  -1(3)2-
                // Build network from our_id to node6:
                //
                //        -1(1)2-  node0  -1(3)2-
@@ -2152,8 +2152,8 @@ mod tests {
 
                let (our_privkey, _, privkeys, _) = get_nodes(&secp_ctx);
 
 
                let (our_privkey, _, privkeys, _) = get_nodes(&secp_ctx);
 
-               add_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, &privkeys[0], ChannelFeatures::from_le_bytes(id_to_feature_flags(1)), 1);
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
+               add_channel(&gossip_sync, &secp_ctx, &our_privkey, &privkeys[0], ChannelFeatures::from_le_bytes(id_to_feature_flags(1)), 1);
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 1,
                        timestamp: 1,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 1,
                        timestamp: 1,
@@ -2166,10 +2166,10 @@ mod tests {
                        excess_data: Vec::new()
                });
 
                        excess_data: Vec::new()
                });
 
-               add_or_update_node(&net_graph_msg_handler, &secp_ctx, &privkeys[0], NodeFeatures::from_le_bytes(id_to_feature_flags(1)), 0);
+               add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[0], NodeFeatures::from_le_bytes(id_to_feature_flags(1)), 0);
 
 
-               add_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, &privkeys[1], ChannelFeatures::from_le_bytes(id_to_feature_flags(2)), 2);
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               add_channel(&gossip_sync, &secp_ctx, &our_privkey, &privkeys[1], ChannelFeatures::from_le_bytes(id_to_feature_flags(2)), 2);
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 1,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 1,
@@ -2181,7 +2181,7 @@ mod tests {
                        fee_proportional_millionths: u32::max_value(),
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: u32::max_value(),
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 1,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 1,
@@ -2194,10 +2194,10 @@ mod tests {
                        excess_data: Vec::new()
                });
 
                        excess_data: Vec::new()
                });
 
-               add_or_update_node(&net_graph_msg_handler, &secp_ctx, &privkeys[1], NodeFeatures::from_le_bytes(id_to_feature_flags(2)), 0);
+               add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[1], NodeFeatures::from_le_bytes(id_to_feature_flags(2)), 0);
 
 
-               add_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, &privkeys[7], ChannelFeatures::from_le_bytes(id_to_feature_flags(12)), 12);
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               add_channel(&gossip_sync, &secp_ctx, &our_privkey, &privkeys[7], ChannelFeatures::from_le_bytes(id_to_feature_flags(12)), 12);
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 12,
                        timestamp: 1,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 12,
                        timestamp: 1,
@@ -2209,7 +2209,7 @@ mod tests {
                        fee_proportional_millionths: u32::max_value(),
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: u32::max_value(),
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[7], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[7], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 12,
                        timestamp: 1,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 12,
                        timestamp: 1,
@@ -2222,10 +2222,10 @@ mod tests {
                        excess_data: Vec::new()
                });
 
                        excess_data: Vec::new()
                });
 
-               add_or_update_node(&net_graph_msg_handler, &secp_ctx, &privkeys[7], NodeFeatures::from_le_bytes(id_to_feature_flags(8)), 0);
+               add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[7], NodeFeatures::from_le_bytes(id_to_feature_flags(8)), 0);
 
 
-               add_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[0], &privkeys[2], ChannelFeatures::from_le_bytes(id_to_feature_flags(3)), 3);
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
+               add_channel(&gossip_sync, &secp_ctx, &privkeys[0], &privkeys[2], ChannelFeatures::from_le_bytes(id_to_feature_flags(3)), 3);
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 3,
                        timestamp: 1,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 3,
                        timestamp: 1,
@@ -2237,7 +2237,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 3,
                        timestamp: 1,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 3,
                        timestamp: 1,
@@ -2250,8 +2250,8 @@ mod tests {
                        excess_data: Vec::new()
                });
 
                        excess_data: Vec::new()
                });
 
-               add_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[1], &privkeys[2], ChannelFeatures::from_le_bytes(id_to_feature_flags(4)), 4);
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
+               add_channel(&gossip_sync, &secp_ctx, &privkeys[1], &privkeys[2], ChannelFeatures::from_le_bytes(id_to_feature_flags(4)), 4);
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 4,
                        timestamp: 1,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 4,
                        timestamp: 1,
@@ -2263,7 +2263,7 @@ mod tests {
                        fee_proportional_millionths: 1000000,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 1000000,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 4,
                        timestamp: 1,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 4,
                        timestamp: 1,
@@ -2276,8 +2276,8 @@ mod tests {
                        excess_data: Vec::new()
                });
 
                        excess_data: Vec::new()
                });
 
-               add_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[7], &privkeys[2], ChannelFeatures::from_le_bytes(id_to_feature_flags(13)), 13);
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[7], UnsignedChannelUpdate {
+               add_channel(&gossip_sync, &secp_ctx, &privkeys[7], &privkeys[2], ChannelFeatures::from_le_bytes(id_to_feature_flags(13)), 13);
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[7], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 13,
                        timestamp: 1,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 13,
                        timestamp: 1,
@@ -2289,7 +2289,7 @@ mod tests {
                        fee_proportional_millionths: 2000000,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 2000000,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 13,
                        timestamp: 1,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 13,
                        timestamp: 1,
@@ -2302,10 +2302,10 @@ mod tests {
                        excess_data: Vec::new()
                });
 
                        excess_data: Vec::new()
                });
 
-               add_or_update_node(&net_graph_msg_handler, &secp_ctx, &privkeys[2], NodeFeatures::from_le_bytes(id_to_feature_flags(3)), 0);
+               add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[2], NodeFeatures::from_le_bytes(id_to_feature_flags(3)), 0);
 
 
-               add_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], &privkeys[4], ChannelFeatures::from_le_bytes(id_to_feature_flags(6)), 6);
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
+               add_channel(&gossip_sync, &secp_ctx, &privkeys[2], &privkeys[4], ChannelFeatures::from_le_bytes(id_to_feature_flags(6)), 6);
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 6,
                        timestamp: 1,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 6,
                        timestamp: 1,
@@ -2317,7 +2317,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[4], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[4], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 6,
                        timestamp: 1,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 6,
                        timestamp: 1,
@@ -2330,8 +2330,8 @@ mod tests {
                        excess_data: Vec::new(),
                });
 
                        excess_data: Vec::new(),
                });
 
-               add_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[4], &privkeys[3], ChannelFeatures::from_le_bytes(id_to_feature_flags(11)), 11);
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[4], UnsignedChannelUpdate {
+               add_channel(&gossip_sync, &secp_ctx, &privkeys[4], &privkeys[3], ChannelFeatures::from_le_bytes(id_to_feature_flags(11)), 11);
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[4], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 11,
                        timestamp: 1,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 11,
                        timestamp: 1,
@@ -2343,7 +2343,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[3], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[3], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 11,
                        timestamp: 1,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 11,
                        timestamp: 1,
@@ -2356,12 +2356,12 @@ mod tests {
                        excess_data: Vec::new()
                });
 
                        excess_data: Vec::new()
                });
 
-               add_or_update_node(&net_graph_msg_handler, &secp_ctx, &privkeys[4], NodeFeatures::from_le_bytes(id_to_feature_flags(5)), 0);
+               add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[4], NodeFeatures::from_le_bytes(id_to_feature_flags(5)), 0);
 
 
-               add_or_update_node(&net_graph_msg_handler, &secp_ctx, &privkeys[3], NodeFeatures::from_le_bytes(id_to_feature_flags(4)), 0);
+               add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[3], NodeFeatures::from_le_bytes(id_to_feature_flags(4)), 0);
 
 
-               add_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], &privkeys[5], ChannelFeatures::from_le_bytes(id_to_feature_flags(7)), 7);
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
+               add_channel(&gossip_sync, &secp_ctx, &privkeys[2], &privkeys[5], ChannelFeatures::from_le_bytes(id_to_feature_flags(7)), 7);
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 7,
                        timestamp: 1,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 7,
                        timestamp: 1,
@@ -2373,7 +2373,7 @@ mod tests {
                        fee_proportional_millionths: 1000000,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 1000000,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[5], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[5], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 7,
                        timestamp: 1,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 7,
                        timestamp: 1,
@@ -2386,9 +2386,9 @@ mod tests {
                        excess_data: Vec::new()
                });
 
                        excess_data: Vec::new()
                });
 
-               add_or_update_node(&net_graph_msg_handler, &secp_ctx, &privkeys[5], NodeFeatures::from_le_bytes(id_to_feature_flags(6)), 0);
+               add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[5], NodeFeatures::from_le_bytes(id_to_feature_flags(6)), 0);
 
 
-               (secp_ctx, network_graph, net_graph_msg_handler, chain_monitor, logger)
+               (secp_ctx, network_graph, gossip_sync, chain_monitor, logger)
        }
 
        #[test]
        }
 
        #[test]
@@ -2448,7 +2448,7 @@ mod tests {
 
        #[test]
        fn htlc_minimum_test() {
 
        #[test]
        fn htlc_minimum_test() {
-               let (secp_ctx, network_graph, net_graph_msg_handler, _, logger) = build_graph();
+               let (secp_ctx, network_graph, gossip_sync, _, logger) = build_graph();
                let (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
                let payment_params = PaymentParameters::from_node_id(nodes[2]);
                let scorer = test_utils::TestScorer::with_penalty(0);
                let (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
                let payment_params = PaymentParameters::from_node_id(nodes[2]);
                let scorer = test_utils::TestScorer::with_penalty(0);
@@ -2458,7 +2458,7 @@ mod tests {
                // Simple route to 2 via 1
 
                // Disable other paths
                // Simple route to 2 via 1
 
                // Disable other paths
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 12,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 12,
                        timestamp: 2,
@@ -2470,7 +2470,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 3,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 3,
                        timestamp: 2,
@@ -2482,7 +2482,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[7], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[7], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 13,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 13,
                        timestamp: 2,
@@ -2494,7 +2494,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 6,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 6,
                        timestamp: 2,
@@ -2506,7 +2506,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 7,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 7,
                        timestamp: 2,
@@ -2521,7 +2521,7 @@ mod tests {
 
                // Check against amount_to_transfer_over_msat.
                // Set minimal HTLC of 200_000_000 msat.
 
                // Check against amount_to_transfer_over_msat.
                // Set minimal HTLC of 200_000_000 msat.
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 3,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 3,
@@ -2536,7 +2536,7 @@ mod tests {
 
                // Second hop only allows to forward 199_999_999 at most, thus not allowing the first hop to
                // be used.
 
                // Second hop only allows to forward 199_999_999 at most, thus not allowing the first hop to
                // be used.
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 4,
                        timestamp: 3,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 4,
                        timestamp: 3,
@@ -2555,7 +2555,7 @@ mod tests {
                } else { panic!(); }
 
                // Lift the restriction on the first hop.
                } else { panic!(); }
 
                // Lift the restriction on the first hop.
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 4,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 4,
@@ -2575,7 +2575,7 @@ mod tests {
 
        #[test]
        fn htlc_minimum_overpay_test() {
 
        #[test]
        fn htlc_minimum_overpay_test() {
-               let (secp_ctx, network_graph, net_graph_msg_handler, _, logger) = build_graph();
+               let (secp_ctx, network_graph, gossip_sync, _, logger) = build_graph();
                let (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
                let payment_params = PaymentParameters::from_node_id(nodes[2]).with_features(InvoiceFeatures::known());
                let scorer = test_utils::TestScorer::with_penalty(0);
                let (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
                let payment_params = PaymentParameters::from_node_id(nodes[2]).with_features(InvoiceFeatures::known());
                let scorer = test_utils::TestScorer::with_penalty(0);
@@ -2585,7 +2585,7 @@ mod tests {
                // A route to node#2 via two paths.
                // One path allows transferring 35-40 sats, another one also allows 35-40 sats.
                // Thus, they can't send 60 without overpaying.
                // A route to node#2 via two paths.
                // One path allows transferring 35-40 sats, another one also allows 35-40 sats.
                // Thus, they can't send 60 without overpaying.
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 2,
@@ -2597,7 +2597,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 12,
                        timestamp: 3,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 12,
                        timestamp: 3,
@@ -2611,7 +2611,7 @@ mod tests {
                });
 
                // Make 0 fee.
                });
 
                // Make 0 fee.
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[7], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[7], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 13,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 13,
                        timestamp: 2,
@@ -2623,7 +2623,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 4,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 4,
                        timestamp: 2,
@@ -2637,7 +2637,7 @@ mod tests {
                });
 
                // Disable other paths
                });
 
                // Disable other paths
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 1,
                        timestamp: 3,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 1,
                        timestamp: 3,
@@ -2658,7 +2658,7 @@ mod tests {
 
                // Now, test that if there are 2 paths, a "cheaper" by fee path wouldn't be prioritized
                // while taking even more fee to match htlc_minimum_msat.
 
                // Now, test that if there are 2 paths, a "cheaper" by fee path wouldn't be prioritized
                // while taking even more fee to match htlc_minimum_msat.
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 12,
                        timestamp: 4,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 12,
                        timestamp: 4,
@@ -2670,7 +2670,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 3,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 3,
@@ -2682,7 +2682,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 4,
                        timestamp: 4,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 4,
                        timestamp: 4,
@@ -2713,7 +2713,7 @@ mod tests {
 
        #[test]
        fn disable_channels_test() {
 
        #[test]
        fn disable_channels_test() {
-               let (secp_ctx, network_graph, net_graph_msg_handler, _, logger) = build_graph();
+               let (secp_ctx, network_graph, gossip_sync, _, logger) = build_graph();
                let (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
                let payment_params = PaymentParameters::from_node_id(nodes[2]);
                let scorer = test_utils::TestScorer::with_penalty(0);
                let (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
                let payment_params = PaymentParameters::from_node_id(nodes[2]);
                let scorer = test_utils::TestScorer::with_penalty(0);
@@ -2721,7 +2721,7 @@ mod tests {
                let random_seed_bytes = keys_manager.get_secure_random_bytes();
 
                // // Disable channels 4 and 12 by flags=2
                let random_seed_bytes = keys_manager.get_secure_random_bytes();
 
                // // Disable channels 4 and 12 by flags=2
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 4,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 4,
                        timestamp: 2,
@@ -2733,7 +2733,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 12,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 12,
                        timestamp: 2,
@@ -2773,7 +2773,7 @@ mod tests {
 
        #[test]
        fn disable_node_test() {
 
        #[test]
        fn disable_node_test() {
-               let (secp_ctx, network_graph, net_graph_msg_handler, _, logger) = build_graph();
+               let (secp_ctx, network_graph, gossip_sync, _, logger) = build_graph();
                let (_, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
                let payment_params = PaymentParameters::from_node_id(nodes[2]);
                let scorer = test_utils::TestScorer::with_penalty(0);
                let (_, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
                let payment_params = PaymentParameters::from_node_id(nodes[2]);
                let scorer = test_utils::TestScorer::with_penalty(0);
@@ -2783,9 +2783,9 @@ mod tests {
                // Disable nodes 1, 2, and 8 by requiring unknown feature bits
                let mut unknown_features = NodeFeatures::known();
                unknown_features.set_unknown_feature_required();
                // Disable nodes 1, 2, and 8 by requiring unknown feature bits
                let mut unknown_features = NodeFeatures::known();
                unknown_features.set_unknown_feature_required();
-               add_or_update_node(&net_graph_msg_handler, &secp_ctx, &privkeys[0], unknown_features.clone(), 1);
-               add_or_update_node(&net_graph_msg_handler, &secp_ctx, &privkeys[1], unknown_features.clone(), 1);
-               add_or_update_node(&net_graph_msg_handler, &secp_ctx, &privkeys[7], unknown_features.clone(), 1);
+               add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[0], unknown_features.clone(), 1);
+               add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[1], unknown_features.clone(), 1);
+               add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[7], unknown_features.clone(), 1);
 
                // If all nodes require some features we don't understand, route should fail
                if let Err(LightningError{err, action: ErrorAction::IgnoreError}) = get_route(&our_id, &payment_params, &network_graph.read_only(), None, 100, 42, Arc::clone(&logger), &scorer, &random_seed_bytes) {
 
                // If all nodes require some features we don't understand, route should fail
                if let Err(LightningError{err, action: ErrorAction::IgnoreError}) = get_route(&our_id, &payment_params, &network_graph.read_only(), None, 100, 42, Arc::clone(&logger), &scorer, &random_seed_bytes) {
@@ -3128,7 +3128,7 @@ mod tests {
 
        #[test]
        fn multi_hint_last_hops_test() {
 
        #[test]
        fn multi_hint_last_hops_test() {
-               let (secp_ctx, network_graph, net_graph_msg_handler, _, logger) = build_graph();
+               let (secp_ctx, network_graph, gossip_sync, _, logger) = build_graph();
                let (_, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
                let last_hops = multi_hop_last_hops_hint([nodes[2], nodes[3]]);
                let payment_params = PaymentParameters::from_node_id(nodes[6]).with_route_hints(last_hops.clone());
                let (_, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
                let last_hops = multi_hop_last_hops_hint([nodes[2], nodes[3]]);
                let payment_params = PaymentParameters::from_node_id(nodes[6]).with_route_hints(last_hops.clone());
@@ -3139,7 +3139,7 @@ mod tests {
                // Test shows that multiple hop hints are considered.
 
                // Disabling channels 6 & 7 by flags=2
                // Test shows that multiple hop hints are considered.
 
                // Disabling channels 6 & 7 by flags=2
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 6,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 6,
                        timestamp: 2,
@@ -3151,7 +3151,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 7,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 7,
                        timestamp: 2,
@@ -3198,7 +3198,7 @@ mod tests {
 
        #[test]
        fn private_multi_hint_last_hops_test() {
 
        #[test]
        fn private_multi_hint_last_hops_test() {
-               let (secp_ctx, network_graph, net_graph_msg_handler, _, logger) = build_graph();
+               let (secp_ctx, network_graph, gossip_sync, _, logger) = build_graph();
                let (_, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
 
                let non_announced_privkey = SecretKey::from_slice(&hex::decode(format!("{:02x}", 0xf0).repeat(32)).unwrap()[..]).unwrap();
                let (_, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
 
                let non_announced_privkey = SecretKey::from_slice(&hex::decode(format!("{:02x}", 0xf0).repeat(32)).unwrap()[..]).unwrap();
@@ -3211,7 +3211,7 @@ mod tests {
                // Test shows that multiple hop hints are considered.
 
                // Disabling channels 6 & 7 by flags=2
                // Test shows that multiple hop hints are considered.
 
                // Disabling channels 6 & 7 by flags=2
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 6,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 6,
                        timestamp: 2,
@@ -3223,7 +3223,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 7,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 7,
                        timestamp: 2,
@@ -3541,7 +3541,7 @@ mod tests {
        fn available_amount_while_routing_test() {
                // Tests whether we choose the correct available channel amount while routing.
 
        fn available_amount_while_routing_test() {
                // Tests whether we choose the correct available channel amount while routing.
 
-               let (secp_ctx, network_graph, mut net_graph_msg_handler, chain_monitor, logger) = build_graph();
+               let (secp_ctx, network_graph, mut gossip_sync, chain_monitor, logger) = build_graph();
                let (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
                let scorer = test_utils::TestScorer::with_penalty(0);
                let keys_manager = test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
                let (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
                let scorer = test_utils::TestScorer::with_penalty(0);
                let keys_manager = test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
@@ -3552,7 +3552,7 @@ mod tests {
                // our node to node2 via node0: channels {1, 3}.
 
                // First disable all other paths.
                // our node to node2 via node0: channels {1, 3}.
 
                // First disable all other paths.
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 2,
@@ -3564,7 +3564,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 12,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 12,
                        timestamp: 2,
@@ -3579,7 +3579,7 @@ mod tests {
 
                // Make the first channel (#1) very permissive,
                // and we will be testing all limits on the second channel.
 
                // Make the first channel (#1) very permissive,
                // and we will be testing all limits on the second channel.
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 1,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 1,
                        timestamp: 2,
@@ -3594,7 +3594,7 @@ mod tests {
 
                // First, let's see if routing works if we have absolutely no idea about the available amount.
                // In this case, it should be set to 250_000 sats.
 
                // First, let's see if routing works if we have absolutely no idea about the available amount.
                // In this case, it should be set to 250_000 sats.
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 3,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 3,
                        timestamp: 2,
@@ -3627,7 +3627,7 @@ mod tests {
 
                // Check that setting next_outbound_htlc_limit_msat in first_hops limits the channels.
                // Disable channel #1 and use another first hop.
 
                // Check that setting next_outbound_htlc_limit_msat in first_hops limits the channels.
                // Disable channel #1 and use another first hop.
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 1,
                        timestamp: 3,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 1,
                        timestamp: 3,
@@ -3662,7 +3662,7 @@ mod tests {
                }
 
                // Enable channel #1 back.
                }
 
                // Enable channel #1 back.
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 1,
                        timestamp: 4,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 1,
                        timestamp: 4,
@@ -3677,7 +3677,7 @@ mod tests {
 
 
                // Now let's see if routing works if we know only htlc_maximum_msat.
 
 
                // Now let's see if routing works if we know only htlc_maximum_msat.
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 3,
                        timestamp: 3,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 3,
                        timestamp: 3,
@@ -3712,7 +3712,7 @@ mod tests {
 
                // We can't change UTXO capacity on the fly, so we'll disable
                // the existing channel and add another one with the capacity we need.
 
                // We can't change UTXO capacity on the fly, so we'll disable
                // the existing channel and add another one with the capacity we need.
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 3,
                        timestamp: 4,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 3,
                        timestamp: 4,
@@ -3732,10 +3732,10 @@ mod tests {
                .push_opcode(opcodes::all::OP_CHECKMULTISIG).into_script().to_v0_p2wsh();
 
                *chain_monitor.utxo_ret.lock().unwrap() = Ok(TxOut { value: 15, script_pubkey: good_script.clone() });
                .push_opcode(opcodes::all::OP_CHECKMULTISIG).into_script().to_v0_p2wsh();
 
                *chain_monitor.utxo_ret.lock().unwrap() = Ok(TxOut { value: 15, script_pubkey: good_script.clone() });
-               net_graph_msg_handler.add_chain_access(Some(chain_monitor));
+               gossip_sync.add_chain_access(Some(chain_monitor));
 
 
-               add_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[0], &privkeys[2], ChannelFeatures::from_le_bytes(id_to_feature_flags(3)), 333);
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
+               add_channel(&gossip_sync, &secp_ctx, &privkeys[0], &privkeys[2], ChannelFeatures::from_le_bytes(id_to_feature_flags(3)), 333);
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 333,
                        timestamp: 1,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 333,
                        timestamp: 1,
@@ -3747,7 +3747,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 333,
                        timestamp: 1,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 333,
                        timestamp: 1,
@@ -3779,7 +3779,7 @@ mod tests {
                }
 
                // Now let's see if routing chooses htlc_maximum_msat over UTXO capacity.
                }
 
                // Now let's see if routing chooses htlc_maximum_msat over UTXO capacity.
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 333,
                        timestamp: 6,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 333,
                        timestamp: 6,
@@ -3815,7 +3815,7 @@ mod tests {
        fn available_liquidity_last_hop_test() {
                // Check that available liquidity properly limits the path even when only
                // one of the latter hops is limited.
        fn available_liquidity_last_hop_test() {
                // Check that available liquidity properly limits the path even when only
                // one of the latter hops is limited.
-               let (secp_ctx, network_graph, net_graph_msg_handler, _, logger) = build_graph();
+               let (secp_ctx, network_graph, gossip_sync, _, logger) = build_graph();
                let (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
                let scorer = test_utils::TestScorer::with_penalty(0);
                let keys_manager = test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
                let (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
                let scorer = test_utils::TestScorer::with_penalty(0);
                let keys_manager = test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
@@ -3827,7 +3827,7 @@ mod tests {
                // Total capacity: 50 sats.
 
                // Disable other potential paths.
                // Total capacity: 50 sats.
 
                // Disable other potential paths.
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 2,
@@ -3839,7 +3839,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 7,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 7,
                        timestamp: 2,
@@ -3854,7 +3854,7 @@ mod tests {
 
                // Limit capacities
 
 
                // Limit capacities
 
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 12,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 12,
                        timestamp: 2,
@@ -3866,7 +3866,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[7], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[7], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 13,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 13,
                        timestamp: 2,
@@ -3879,7 +3879,7 @@ mod tests {
                        excess_data: Vec::new()
                });
 
                        excess_data: Vec::new()
                });
 
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 6,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 6,
                        timestamp: 2,
@@ -3891,7 +3891,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[4], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[4], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 11,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 11,
                        timestamp: 2,
@@ -3940,7 +3940,7 @@ mod tests {
 
        #[test]
        fn ignore_fee_first_hop_test() {
 
        #[test]
        fn ignore_fee_first_hop_test() {
-               let (secp_ctx, network_graph, net_graph_msg_handler, _, logger) = build_graph();
+               let (secp_ctx, network_graph, gossip_sync, _, logger) = build_graph();
                let (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
                let scorer = test_utils::TestScorer::with_penalty(0);
                let keys_manager = test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
                let (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
                let scorer = test_utils::TestScorer::with_penalty(0);
                let keys_manager = test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
@@ -3948,7 +3948,7 @@ mod tests {
                let payment_params = PaymentParameters::from_node_id(nodes[2]);
 
                // Path via node0 is channels {1, 3}. Limit them to 100 and 50 sats (total limit 50).
                let payment_params = PaymentParameters::from_node_id(nodes[2]);
 
                // Path via node0 is channels {1, 3}. Limit them to 100 and 50 sats (total limit 50).
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 1,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 1,
                        timestamp: 2,
@@ -3960,7 +3960,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 3,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 3,
                        timestamp: 2,
@@ -3988,7 +3988,7 @@ mod tests {
 
        #[test]
        fn simple_mpp_route_test() {
 
        #[test]
        fn simple_mpp_route_test() {
-               let (secp_ctx, network_graph, net_graph_msg_handler, _, logger) = build_graph();
+               let (secp_ctx, network_graph, gossip_sync, _, logger) = build_graph();
                let (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
                let scorer = test_utils::TestScorer::with_penalty(0);
                let keys_manager = test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
                let (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
                let scorer = test_utils::TestScorer::with_penalty(0);
                let keys_manager = test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
@@ -4004,7 +4004,7 @@ mod tests {
                // Their aggregate capacity will be 50 + 60 + 180 = 290 sats.
 
                // Path via node0 is channels {1, 3}. Limit them to 100 and 50 sats (total limit 50).
                // Their aggregate capacity will be 50 + 60 + 180 = 290 sats.
 
                // Path via node0 is channels {1, 3}. Limit them to 100 and 50 sats (total limit 50).
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 1,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 1,
                        timestamp: 2,
@@ -4016,7 +4016,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 3,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 3,
                        timestamp: 2,
@@ -4031,7 +4031,7 @@ mod tests {
 
                // Path via node7 is channels {12, 13}. Limit them to 60 and 60 sats
                // (total limit 60).
 
                // Path via node7 is channels {12, 13}. Limit them to 60 and 60 sats
                // (total limit 60).
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 12,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 12,
                        timestamp: 2,
@@ -4043,7 +4043,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[7], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[7], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 13,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 13,
                        timestamp: 2,
@@ -4058,7 +4058,7 @@ mod tests {
 
                // Path via node1 is channels {2, 4}. Limit them to 200 and 180 sats
                // (total capacity 180 sats).
 
                // Path via node1 is channels {2, 4}. Limit them to 200 and 180 sats
                // (total capacity 180 sats).
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 2,
@@ -4070,7 +4070,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 4,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 4,
                        timestamp: 2,
@@ -4121,7 +4121,7 @@ mod tests {
 
        #[test]
        fn long_mpp_route_test() {
 
        #[test]
        fn long_mpp_route_test() {
-               let (secp_ctx, network_graph, net_graph_msg_handler, _, logger) = build_graph();
+               let (secp_ctx, network_graph, gossip_sync, _, logger) = build_graph();
                let (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
                let scorer = test_utils::TestScorer::with_penalty(0);
                let keys_manager = test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
                let (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
                let scorer = test_utils::TestScorer::with_penalty(0);
                let keys_manager = test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
@@ -4136,7 +4136,7 @@ mod tests {
                // are used twice will have 200 sats capacity.
 
                // Disable other potential paths.
                // are used twice will have 200 sats capacity.
 
                // Disable other potential paths.
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 2,
@@ -4148,7 +4148,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 7,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 7,
                        timestamp: 2,
@@ -4162,7 +4162,7 @@ mod tests {
                });
 
                // Path via {node0, node2} is channels {1, 3, 5}.
                });
 
                // Path via {node0, node2} is channels {1, 3, 5}.
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 1,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 1,
                        timestamp: 2,
@@ -4174,7 +4174,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 3,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 3,
                        timestamp: 2,
@@ -4188,8 +4188,8 @@ mod tests {
                });
 
                // Capacity of 200 sats because this channel will be used by 3rd path as well.
                });
 
                // Capacity of 200 sats because this channel will be used by 3rd path as well.
-               add_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], &privkeys[3], ChannelFeatures::from_le_bytes(id_to_feature_flags(5)), 5);
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
+               add_channel(&gossip_sync, &secp_ctx, &privkeys[2], &privkeys[3], ChannelFeatures::from_le_bytes(id_to_feature_flags(5)), 5);
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 5,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 5,
                        timestamp: 2,
@@ -4205,7 +4205,7 @@ mod tests {
                // Path via {node7, node2, node4} is channels {12, 13, 6, 11}.
                // Add 100 sats to the capacities of {12, 13}, because these channels
                // are also used for 3rd path. 100 sats for the rest. Total capacity: 100 sats.
                // Path via {node7, node2, node4} is channels {12, 13, 6, 11}.
                // Add 100 sats to the capacities of {12, 13}, because these channels
                // are also used for 3rd path. 100 sats for the rest. Total capacity: 100 sats.
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 12,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 12,
                        timestamp: 2,
@@ -4217,7 +4217,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[7], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[7], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 13,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 13,
                        timestamp: 2,
@@ -4230,7 +4230,7 @@ mod tests {
                        excess_data: Vec::new()
                });
 
                        excess_data: Vec::new()
                });
 
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 6,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 6,
                        timestamp: 2,
@@ -4242,7 +4242,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[4], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[4], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 11,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 11,
                        timestamp: 2,
@@ -4285,7 +4285,7 @@ mod tests {
 
        #[test]
        fn mpp_cheaper_route_test() {
 
        #[test]
        fn mpp_cheaper_route_test() {
-               let (secp_ctx, network_graph, net_graph_msg_handler, _, logger) = build_graph();
+               let (secp_ctx, network_graph, gossip_sync, _, logger) = build_graph();
                let (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
                let scorer = test_utils::TestScorer::with_penalty(0);
                let keys_manager = test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
                let (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
                let scorer = test_utils::TestScorer::with_penalty(0);
                let keys_manager = test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
@@ -4304,7 +4304,7 @@ mod tests {
                // are used twice will have 200 sats capacity.
 
                // Disable other potential paths.
                // are used twice will have 200 sats capacity.
 
                // Disable other potential paths.
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 2,
@@ -4316,7 +4316,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 7,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 7,
                        timestamp: 2,
@@ -4330,7 +4330,7 @@ mod tests {
                });
 
                // Path via {node0, node2} is channels {1, 3, 5}.
                });
 
                // Path via {node0, node2} is channels {1, 3, 5}.
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 1,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 1,
                        timestamp: 2,
@@ -4342,7 +4342,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 3,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 3,
                        timestamp: 2,
@@ -4356,8 +4356,8 @@ mod tests {
                });
 
                // Capacity of 200 sats because this channel will be used by 3rd path as well.
                });
 
                // Capacity of 200 sats because this channel will be used by 3rd path as well.
-               add_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], &privkeys[3], ChannelFeatures::from_le_bytes(id_to_feature_flags(5)), 5);
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
+               add_channel(&gossip_sync, &secp_ctx, &privkeys[2], &privkeys[3], ChannelFeatures::from_le_bytes(id_to_feature_flags(5)), 5);
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 5,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 5,
                        timestamp: 2,
@@ -4373,7 +4373,7 @@ mod tests {
                // Path via {node7, node2, node4} is channels {12, 13, 6, 11}.
                // Add 100 sats to the capacities of {12, 13}, because these channels
                // are also used for 3rd path. 100 sats for the rest. Total capacity: 100 sats.
                // Path via {node7, node2, node4} is channels {12, 13, 6, 11}.
                // Add 100 sats to the capacities of {12, 13}, because these channels
                // are also used for 3rd path. 100 sats for the rest. Total capacity: 100 sats.
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 12,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 12,
                        timestamp: 2,
@@ -4385,7 +4385,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[7], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[7], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 13,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 13,
                        timestamp: 2,
@@ -4398,7 +4398,7 @@ mod tests {
                        excess_data: Vec::new()
                });
 
                        excess_data: Vec::new()
                });
 
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 6,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 6,
                        timestamp: 2,
@@ -4410,7 +4410,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[4], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[4], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 11,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 11,
                        timestamp: 2,
@@ -4454,7 +4454,7 @@ mod tests {
                // This test makes sure that MPP algorithm properly takes into account
                // fees charged on the channels, by making the fees impactful:
                // if the fee is not properly accounted for, the behavior is different.
                // This test makes sure that MPP algorithm properly takes into account
                // fees charged on the channels, by making the fees impactful:
                // if the fee is not properly accounted for, the behavior is different.
-               let (secp_ctx, network_graph, net_graph_msg_handler, _, logger) = build_graph();
+               let (secp_ctx, network_graph, gossip_sync, _, logger) = build_graph();
                let (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
                let scorer = test_utils::TestScorer::with_penalty(0);
                let keys_manager = test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
                let (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
                let scorer = test_utils::TestScorer::with_penalty(0);
                let keys_manager = test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
@@ -4471,7 +4471,7 @@ mod tests {
                // It's fine to ignore this concern for now.
 
                // Disable other potential paths.
                // It's fine to ignore this concern for now.
 
                // Disable other potential paths.
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 2,
@@ -4484,7 +4484,7 @@ mod tests {
                        excess_data: Vec::new()
                });
 
                        excess_data: Vec::new()
                });
 
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 7,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 7,
                        timestamp: 2,
@@ -4498,7 +4498,7 @@ mod tests {
                });
 
                // Path via {node0, node2} is channels {1, 3, 5}.
                });
 
                // Path via {node0, node2} is channels {1, 3, 5}.
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 1,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 1,
                        timestamp: 2,
@@ -4510,7 +4510,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 3,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 3,
                        timestamp: 2,
@@ -4523,8 +4523,8 @@ mod tests {
                        excess_data: Vec::new()
                });
 
                        excess_data: Vec::new()
                });
 
-               add_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], &privkeys[3], ChannelFeatures::from_le_bytes(id_to_feature_flags(5)), 5);
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
+               add_channel(&gossip_sync, &secp_ctx, &privkeys[2], &privkeys[3], ChannelFeatures::from_le_bytes(id_to_feature_flags(5)), 5);
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 5,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 5,
                        timestamp: 2,
@@ -4547,7 +4547,7 @@ mod tests {
                // - channel 12 capacity is 250 sats
                // - fee for channel 6 is 150 sats
                // Let's test this by enforcing these 2 conditions and removing other limits.
                // - channel 12 capacity is 250 sats
                // - fee for channel 6 is 150 sats
                // Let's test this by enforcing these 2 conditions and removing other limits.
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 12,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 12,
                        timestamp: 2,
@@ -4559,7 +4559,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[7], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[7], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 13,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 13,
                        timestamp: 2,
@@ -4572,7 +4572,7 @@ mod tests {
                        excess_data: Vec::new()
                });
 
                        excess_data: Vec::new()
                });
 
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 6,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 6,
                        timestamp: 2,
@@ -4584,7 +4584,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[4], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[4], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 11,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 11,
                        timestamp: 2,
@@ -4635,7 +4635,7 @@ mod tests {
                // to only have the remaining to-collect amount in available liquidity.
                //
                // This bug appeared in production in some specific channel configurations.
                // to only have the remaining to-collect amount in available liquidity.
                //
                // This bug appeared in production in some specific channel configurations.
-               let (secp_ctx, network_graph, net_graph_msg_handler, _, logger) = build_graph();
+               let (secp_ctx, network_graph, gossip_sync, _, logger) = build_graph();
                let (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
                let scorer = test_utils::TestScorer::with_penalty(0);
                let keys_manager = test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
                let (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
                let scorer = test_utils::TestScorer::with_penalty(0);
                let keys_manager = test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
@@ -4655,7 +4655,7 @@ mod tests {
                // would first use the no-fee route and then fail to find a path along the second route as
                // we think we can only send up to 1 additional sat over the last-hop but refuse to as its
                // under 5% of our payment amount.
                // would first use the no-fee route and then fail to find a path along the second route as
                // we think we can only send up to 1 additional sat over the last-hop but refuse to as its
                // under 5% of our payment amount.
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 1,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 1,
                        timestamp: 2,
@@ -4667,7 +4667,7 @@ mod tests {
                        fee_proportional_millionths: u32::max_value(),
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: u32::max_value(),
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 2,
@@ -4679,7 +4679,7 @@ mod tests {
                        fee_proportional_millionths: u32::max_value(),
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: u32::max_value(),
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 4,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 4,
                        timestamp: 2,
@@ -4691,7 +4691,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[7], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[7], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 13,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 13,
                        timestamp: 2,
@@ -4725,7 +4725,7 @@ mod tests {
        fn drop_lowest_channel_mpp_route_test() {
                // This test checks that low-capacity channel is dropped when after
                // path finding we realize that we found more capacity than we need.
        fn drop_lowest_channel_mpp_route_test() {
                // This test checks that low-capacity channel is dropped when after
                // path finding we realize that we found more capacity than we need.
-               let (secp_ctx, network_graph, net_graph_msg_handler, _, logger) = build_graph();
+               let (secp_ctx, network_graph, gossip_sync, _, logger) = build_graph();
                let (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
                let scorer = test_utils::TestScorer::with_penalty(0);
                let keys_manager = test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
                let (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
                let scorer = test_utils::TestScorer::with_penalty(0);
                let keys_manager = test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
@@ -4742,7 +4742,7 @@ mod tests {
                // Their aggregate capacity will be 50 + 60 + 20 = 130 sats.
 
                // Path via node0 is channels {1, 3}. Limit them to 100 and 50 sats (total limit 50);
                // Their aggregate capacity will be 50 + 60 + 20 = 130 sats.
 
                // Path via node0 is channels {1, 3}. Limit them to 100 and 50 sats (total limit 50);
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 1,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 1,
                        timestamp: 2,
@@ -4754,7 +4754,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 3,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 3,
                        timestamp: 2,
@@ -4768,7 +4768,7 @@ mod tests {
                });
 
                // Path via node7 is channels {12, 13}. Limit them to 60 and 60 sats (total limit 60);
                });
 
                // Path via node7 is channels {12, 13}. Limit them to 60 and 60 sats (total limit 60);
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 12,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 12,
                        timestamp: 2,
@@ -4780,7 +4780,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[7], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[7], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 13,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 13,
                        timestamp: 2,
@@ -4794,7 +4794,7 @@ mod tests {
                });
 
                // Path via node1 is channels {2, 4}. Limit them to 20 and 20 sats (total capacity 20 sats).
                });
 
                // Path via node1 is channels {2, 4}. Limit them to 20 and 20 sats (total capacity 20 sats).
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 2,
@@ -4806,7 +4806,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 4,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 4,
                        timestamp: 2,
@@ -4884,15 +4884,15 @@ mod tests {
                let secp_ctx = Secp256k1::new();
                let logger = Arc::new(test_utils::TestLogger::new());
                let network = Arc::new(NetworkGraph::new(genesis_block(Network::Testnet).header.block_hash()));
                let secp_ctx = Secp256k1::new();
                let logger = Arc::new(test_utils::TestLogger::new());
                let network = Arc::new(NetworkGraph::new(genesis_block(Network::Testnet).header.block_hash()));
-               let net_graph_msg_handler = NetGraphMsgHandler::new(Arc::clone(&network), None, Arc::clone(&logger));
+               let gossip_sync = P2PGossipSync::new(Arc::clone(&network), None, Arc::clone(&logger));
                let (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
                let scorer = test_utils::TestScorer::with_penalty(0);
                let keys_manager = test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
                let random_seed_bytes = keys_manager.get_secure_random_bytes();
                let payment_params = PaymentParameters::from_node_id(nodes[6]);
 
                let (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
                let scorer = test_utils::TestScorer::with_penalty(0);
                let keys_manager = test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
                let random_seed_bytes = keys_manager.get_secure_random_bytes();
                let payment_params = PaymentParameters::from_node_id(nodes[6]);
 
-               add_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, &privkeys[1], ChannelFeatures::from_le_bytes(id_to_feature_flags(6)), 6);
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               add_channel(&gossip_sync, &secp_ctx, &our_privkey, &privkeys[1], ChannelFeatures::from_le_bytes(id_to_feature_flags(6)), 6);
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 6,
                        timestamp: 1,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 6,
                        timestamp: 1,
@@ -4904,10 +4904,10 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               add_or_update_node(&net_graph_msg_handler, &secp_ctx, &privkeys[1], NodeFeatures::from_le_bytes(id_to_feature_flags(1)), 0);
+               add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[1], NodeFeatures::from_le_bytes(id_to_feature_flags(1)), 0);
 
 
-               add_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[1], &privkeys[4], ChannelFeatures::from_le_bytes(id_to_feature_flags(5)), 5);
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
+               add_channel(&gossip_sync, &secp_ctx, &privkeys[1], &privkeys[4], ChannelFeatures::from_le_bytes(id_to_feature_flags(5)), 5);
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 5,
                        timestamp: 1,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 5,
                        timestamp: 1,
@@ -4919,10 +4919,10 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               add_or_update_node(&net_graph_msg_handler, &secp_ctx, &privkeys[4], NodeFeatures::from_le_bytes(id_to_feature_flags(4)), 0);
+               add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[4], NodeFeatures::from_le_bytes(id_to_feature_flags(4)), 0);
 
 
-               add_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[4], &privkeys[3], ChannelFeatures::from_le_bytes(id_to_feature_flags(4)), 4);
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[4], UnsignedChannelUpdate {
+               add_channel(&gossip_sync, &secp_ctx, &privkeys[4], &privkeys[3], ChannelFeatures::from_le_bytes(id_to_feature_flags(4)), 4);
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[4], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 4,
                        timestamp: 1,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 4,
                        timestamp: 1,
@@ -4934,10 +4934,10 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               add_or_update_node(&net_graph_msg_handler, &secp_ctx, &privkeys[3], NodeFeatures::from_le_bytes(id_to_feature_flags(3)), 0);
+               add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[3], NodeFeatures::from_le_bytes(id_to_feature_flags(3)), 0);
 
 
-               add_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[3], &privkeys[2], ChannelFeatures::from_le_bytes(id_to_feature_flags(3)), 3);
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[3], UnsignedChannelUpdate {
+               add_channel(&gossip_sync, &secp_ctx, &privkeys[3], &privkeys[2], ChannelFeatures::from_le_bytes(id_to_feature_flags(3)), 3);
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[3], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 3,
                        timestamp: 1,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 3,
                        timestamp: 1,
@@ -4949,10 +4949,10 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               add_or_update_node(&net_graph_msg_handler, &secp_ctx, &privkeys[2], NodeFeatures::from_le_bytes(id_to_feature_flags(2)), 0);
+               add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[2], NodeFeatures::from_le_bytes(id_to_feature_flags(2)), 0);
 
 
-               add_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], &privkeys[4], ChannelFeatures::from_le_bytes(id_to_feature_flags(2)), 2);
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
+               add_channel(&gossip_sync, &secp_ctx, &privkeys[2], &privkeys[4], ChannelFeatures::from_le_bytes(id_to_feature_flags(2)), 2);
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 1,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 1,
@@ -4965,8 +4965,8 @@ mod tests {
                        excess_data: Vec::new()
                });
 
                        excess_data: Vec::new()
                });
 
-               add_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[4], &privkeys[6], ChannelFeatures::from_le_bytes(id_to_feature_flags(1)), 1);
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[4], UnsignedChannelUpdate {
+               add_channel(&gossip_sync, &secp_ctx, &privkeys[4], &privkeys[6], ChannelFeatures::from_le_bytes(id_to_feature_flags(1)), 1);
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[4], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 1,
                        timestamp: 1,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 1,
                        timestamp: 1,
@@ -4978,7 +4978,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               add_or_update_node(&net_graph_msg_handler, &secp_ctx, &privkeys[6], NodeFeatures::from_le_bytes(id_to_feature_flags(6)), 0);
+               add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[6], NodeFeatures::from_le_bytes(id_to_feature_flags(6)), 0);
 
                {
                        // Now ensure the route flows simply over nodes 1 and 4 to 6.
 
                {
                        // Now ensure the route flows simply over nodes 1 and 4 to 6.
@@ -5015,7 +5015,7 @@ mod tests {
                // Test that if, while walking the graph, we find a hop that has exactly enough liquidity
                // for us, including later hop fees, we take it. In the first version of our MPP algorithm
                // we calculated fees on a higher value, resulting in us ignoring such paths.
                // Test that if, while walking the graph, we find a hop that has exactly enough liquidity
                // for us, including later hop fees, we take it. In the first version of our MPP algorithm
                // we calculated fees on a higher value, resulting in us ignoring such paths.
-               let (secp_ctx, network_graph, net_graph_msg_handler, _, logger) = build_graph();
+               let (secp_ctx, network_graph, gossip_sync, _, logger) = build_graph();
                let (our_privkey, our_id, _, nodes) = get_nodes(&secp_ctx);
                let scorer = test_utils::TestScorer::with_penalty(0);
                let keys_manager = test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
                let (our_privkey, our_id, _, nodes) = get_nodes(&secp_ctx);
                let scorer = test_utils::TestScorer::with_penalty(0);
                let keys_manager = test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
@@ -5024,7 +5024,7 @@ mod tests {
 
                // We modify the graph to set the htlc_maximum of channel 2 to below the value we wish to
                // send.
 
                // We modify the graph to set the htlc_maximum of channel 2 to below the value we wish to
                // send.
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 2,
@@ -5037,7 +5037,7 @@ mod tests {
                        excess_data: Vec::new()
                });
 
                        excess_data: Vec::new()
                });
 
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 12,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 12,
                        timestamp: 2,
@@ -5079,7 +5079,7 @@ mod tests {
                // htlc_maximum_msat, we don't end up undershooting a later htlc_minimum_msat. In the
                // initial version of MPP we'd accept such routes but reject them while recalculating fees,
                // resulting in us thinking there is no possible path, even if other paths exist.
                // htlc_maximum_msat, we don't end up undershooting a later htlc_minimum_msat. In the
                // initial version of MPP we'd accept such routes but reject them while recalculating fees,
                // resulting in us thinking there is no possible path, even if other paths exist.
-               let (secp_ctx, network_graph, net_graph_msg_handler, _, logger) = build_graph();
+               let (secp_ctx, network_graph, gossip_sync, _, logger) = build_graph();
                let (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
                let scorer = test_utils::TestScorer::with_penalty(0);
                let keys_manager = test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
                let (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
                let scorer = test_utils::TestScorer::with_penalty(0);
                let keys_manager = test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
@@ -5089,7 +5089,7 @@ mod tests {
                // We modify the graph to set the htlc_minimum of channel 2 and 4 as needed - channel 2
                // gets an htlc_maximum_msat of 80_000 and channel 4 an htlc_minimum_msat of 90_000. We
                // then try to send 90_000.
                // We modify the graph to set the htlc_minimum of channel 2 and 4 as needed - channel 2
                // gets an htlc_maximum_msat of 80_000 and channel 4 an htlc_minimum_msat of 90_000. We
                // then try to send 90_000.
-               update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 2,
@@ -5101,7 +5101,7 @@ mod tests {
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
                        fee_proportional_millionths: 0,
                        excess_data: Vec::new()
                });
-               update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
+               update_channel(&gossip_sync, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 4,
                        timestamp: 2,
                        chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 4,
                        timestamp: 2,
index 0a886b93f6e01eb3dc70c967bc8d439ee3805b84..b00cf74e062f0d72cbbea7487e8d69591a378be0 100644 (file)
@@ -337,10 +337,10 @@ pub enum Event {
                /// payment route.
                ///
                /// Should be applied to the [`NetworkGraph`] so that routing decisions can take into
                /// payment route.
                ///
                /// Should be applied to the [`NetworkGraph`] so that routing decisions can take into
-               /// account the update. [`NetGraphMsgHandler`] is capable of doing this.
+               /// account the update. [`P2PGossipSync`] is capable of doing this.
                ///
                /// [`NetworkGraph`]: crate::routing::network_graph::NetworkGraph
                ///
                /// [`NetworkGraph`]: crate::routing::network_graph::NetworkGraph
-               /// [`NetGraphMsgHandler`]: crate::routing::network_graph::NetGraphMsgHandler
+               /// [`P2PGossipSync`]: crate::routing::network_graph::P2PGossipSync
                network_update: Option<NetworkUpdate>,
                /// For both single-path and multi-path payments, this is set if all paths of the payment have
                /// failed. This will be set to false if (1) this is an MPP payment and (2) other parts of the
                network_update: Option<NetworkUpdate>,
                /// For both single-path and multi-path payments, this is set if all paths of the payment have
                /// failed. This will be set to false if (1) this is an MPP payment and (2) other parts of the