+impl<NG: Deref<Target=NetworkGraph<L>>, L: Deref> RapidGossipSync<NG, L> where L::Target: Logger {
+ /// Instantiate a new [`RapidGossipSync`] instance.
+ pub fn new(network_graph: NG) -> Self {
+ Self {
+ network_graph,
+ is_initial_sync_complete: AtomicBool::new(false)
+ }
+ }
+
+ /// Sync gossip data from a file.
+ /// Returns the last sync timestamp to be used the next time rapid sync data is queried.
+ ///
+ /// `network_graph`: The network graph to apply the updates to
+ ///
+ /// `sync_path`: Path to the file where the gossip update data is located
+ ///
+ #[cfg(feature = "std")]
+ pub fn sync_network_graph_with_file_path(
+ &self,
+ sync_path: &str,
+ ) -> Result<u32, GraphSyncError> {
+ let mut file = File::open(sync_path)?;
+ self.update_network_graph_from_byte_stream(&mut file)
+ }
+
+ /// Update network graph from binary data.
+ /// Returns the last sync timestamp to be used the next time rapid sync data is queried.
+ ///
+ /// `network_graph`: network graph to be updated
+ ///
+ /// `update_data`: `&[u8]` binary stream that comprises the update data
+ pub fn update_network_graph(&self, update_data: &[u8]) -> Result<u32, GraphSyncError> {
+ let mut read_cursor = io::Cursor::new(update_data);
+ self.update_network_graph_from_byte_stream(&mut read_cursor)
+ }
+
+ /// Gets a reference to the underlying [`NetworkGraph`] which was provided in
+ /// [`RapidGossipSync::new`].
+ ///
+ /// (C-not exported) as bindings don't support a reference-to-a-reference yet
+ pub fn network_graph(&self) -> &NG {
+ &self.network_graph
+ }
+
+ /// Returns whether a rapid gossip sync has completed at least once.
+ pub fn is_initial_sync_complete(&self) -> bool {
+ self.is_initial_sync_complete.load(Ordering::Acquire)
+ }
+}
+
+#[cfg(feature = "std")]