Implement finding paths for MPP
[rust-lightning] / lightning / src / routing / network_graph.rs
index a16e67529e48243848535e63e27d095c640ba5ef..6856bb16bcfc4bbb221542d92967f7e32fecfa69 100644 (file)
@@ -98,6 +98,13 @@ impl<C: Deref, L: Deref> NetGraphMsgHandler<C, L> where C::Target: chain::Access
                }
        }
 
+       /// Adds a provider used to check new announcements. Does not affect
+       /// existing announcements unless they are updated.
+       /// Add, update or remove the provider would replace the current one.
+       pub fn add_chain_access(&mut self, chain_access: Option<C>) {
+               self.chain_access = chain_access;
+       }
+
        /// Take a read lock on the network_graph and return it in the C-bindings
        /// newtype helper. This is likely only useful when called via the C
        /// bindings as you can call `self.network_graph.read().unwrap()` in Rust
@@ -105,6 +112,18 @@ impl<C: Deref, L: Deref> NetGraphMsgHandler<C, L> where C::Target: chain::Access
        pub fn read_locked_graph<'a>(&'a self) -> LockedNetworkGraph<'a> {
                LockedNetworkGraph(self.network_graph.read().unwrap())
        }
+
+       /// Returns true when a full routing table sync should be performed with a peer.
+       fn should_request_full_sync(&self, _node_id: &PublicKey) -> bool {
+               //TODO: Determine whether to request a full sync based on the network map.
+               const FULL_SYNCS_TO_REQUEST: usize = 5;
+               if self.full_syncs_requested.load(Ordering::Acquire) < FULL_SYNCS_TO_REQUEST {
+                       self.full_syncs_requested.fetch_add(1, Ordering::AcqRel);
+                       true
+               } else {
+                       false
+               }
+       }
 }
 
 impl<'a> LockedNetworkGraph<'a> {
@@ -207,17 +226,6 @@ impl<C: Deref + Sync + Send, L: Deref + Sync + Send> RoutingMessageHandler for N
                result
        }
 
-       fn should_request_full_sync(&self, _node_id: &PublicKey) -> bool {
-               //TODO: Determine whether to request a full sync based on the network map.
-               const FULL_SYNCS_TO_REQUEST: usize = 5;
-               if self.full_syncs_requested.load(Ordering::Acquire) < FULL_SYNCS_TO_REQUEST {
-                       self.full_syncs_requested.fetch_add(1, Ordering::AcqRel);
-                       true
-               } else {
-                       false
-               }
-       }
-
        /// Initiates a stateless sync of routing gossip information with a peer
        /// using gossip_queries. The default strategy used by this implementation
        /// is to sync the full block range with several peers.