_bench_unstable = []
[dependencies]
-lightning = { version = "0.0.111", path = "../lightning" }
+lightning = { version = "0.0.111", path = "../lightning", default-features = false }
bitcoin = { version = "0.29.0", default-features = false }
[dev-dependencies]
use core::fmt::Debug;
-use std::fmt::Formatter;
+use core::fmt::Formatter;
use lightning::ln::msgs::{DecodeError, LightningError};
/// All-encompassing standard error type that processing can return
LightningError(LightningError),
}
-impl From<std::io::Error> for GraphSyncError {
- fn from(error: std::io::Error) -> Self {
+impl From<lightning::io::Error> for GraphSyncError {
+ fn from(error: lightning::io::Error) -> Self {
Self::DecodeError(DecodeError::Io(error.kind()))
}
}
}
impl Debug for GraphSyncError {
- fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+ fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
match self {
GraphSyncError::DecodeError(e) => f.write_fmt(format_args!("DecodeError: {:?}", e)),
GraphSyncError::LightningError(e) => f.write_fmt(format_args!("LightningError: {:?}", e))
//! ```
//! [sync_network_graph_with_file_path]: RapidGossipSync::sync_network_graph_with_file_path
+#![cfg_attr(all(not(feature = "std"), not(test)), no_std)]
+
// Allow and import test features for benching
#![cfg_attr(all(test, feature = "_bench_unstable"), feature(test))]
#[cfg(all(test, feature = "_bench_unstable"))]
extern crate test;
+#[cfg(not(feature = "std"))]
+extern crate alloc;
+
#[cfg(feature = "std")]
use std::fs::File;
use core::ops::Deref;
}
}
+#[cfg(feature = "std")]
#[cfg(test)]
mod tests {
use std::fs;
use crate::error::GraphSyncError;
use crate::RapidGossipSync;
+#[cfg(not(feature = "std"))]
+use alloc::{vec::Vec, borrow::ToOwned};
+
/// The purpose of this prefix is to identify the serialization format, should other rapid gossip
/// sync formats arise in the future.
///
let backdated_timestamp = latest_seen_timestamp.saturating_sub(24 * 3600 * 7);
let node_id_count: u32 = Readable::read(read_cursor)?;
- let mut node_ids: Vec<PublicKey> = Vec::with_capacity(std::cmp::min(
+ let mut node_ids: Vec<PublicKey> = Vec::with_capacity(core::cmp::min(
node_id_count,
MAX_INITIAL_NODE_ID_VECTOR_CAPACITY,
) as usize);
htlc_maximum_msat: default_htlc_maximum_msat,
fee_base_msat: default_fee_base_msat,
fee_proportional_millionths: default_fee_proportional_millionths,
- excess_data: vec![],
+ excess_data: Vec::new(),
}
} else {
// incremental update, field flags will indicate mutated values
htlc_maximum_msat: directional_info.htlc_maximum_msat,
fee_base_msat: directional_info.fees.base_msat,
fee_proportional_millionths: directional_info.fees.proportional_millionths,
- excess_data: vec![],
+ excess_data: Vec::new(),
}
};