"""
[features]
+default = ["std"]
+no-std = ["lightning/no-std"]
+std = ["lightning/std"]
_bench_unstable = []
[dependencies]
#[cfg(all(test, feature = "_bench_unstable"))]
extern crate test;
+#[cfg(feature = "std")]
use std::fs::File;
-use std::ops::Deref;
-use std::sync::atomic::{AtomicBool, Ordering};
+use core::ops::Deref;
+use core::sync::atomic::{AtomicBool, Ordering};
+use lightning::io;
use lightning::routing::gossip::NetworkGraph;
use lightning::util::logger::Logger;
///
/// `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,
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`].
///
-use std::cmp::max;
-use std::io;
-use std::io::Read;
-use std::ops::Deref;
-use std::sync::atomic::Ordering;
+use core::cmp::max;
+use core::ops::Deref;
+use core::sync::atomic::Ordering;
use bitcoin::BlockHash;
use bitcoin::secp256k1::PublicKey;
use lightning::routing::gossip::NetworkGraph;
use lightning::util::logger::Logger;
use lightning::util::ser::{BigSize, Readable};
+use lightning::io;
use crate::error::GraphSyncError;
use crate::RapidGossipSync;
const MAX_INITIAL_NODE_ID_VECTOR_CAPACITY: u32 = 50_000;
impl<NG: Deref<Target=NetworkGraph<L>>, L: Deref> RapidGossipSync<NG, L> where L::Target: Logger {
- /// 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)
- }
-
-
- pub(crate) fn update_network_graph_from_byte_stream<R: Read>(
+ pub(crate) fn update_network_graph_from_byte_stream<R: io::Read>(
&self,
mut read_cursor: &mut R,
) -> Result<u32, GraphSyncError> {
edition = "2018"
[features]
-default = ["lightning/no-std", "lightning-invoice/no-std"]
+default = ["lightning/no-std", "lightning-invoice/no-std", "lightning-rapid-gossip-sync/no-std"]
[dependencies]
lightning = { path = "../lightning", default-features = false }
lightning-invoice = { path = "../lightning-invoice", default-features = false }
+lightning-rapid-gossip-sync = { path = "../lightning-rapid-gossip-sync", default-features = false }