use util::ser::{Writeable, Readable};
use util::logger::Logger;
-use std::cmp;
+use core::cmp;
use std::collections::{HashMap, BinaryHeap};
-use std::ops::Deref;
+use core::ops::Deref;
/// A hop in a route
#[derive(Clone, PartialEq)]
pub paths: Vec<Vec<RouteHop>>,
}
+const SERIALIZATION_VERSION: u8 = 1;
+const MIN_SERIALIZATION_VERSION: u8 = 1;
+
impl Writeable for Route {
fn write<W: ::util::ser::Writer>(&self, writer: &mut W) -> Result<(), ::std::io::Error> {
+ write_ver_prefix!(writer, SERIALIZATION_VERSION, MIN_SERIALIZATION_VERSION);
(self.paths.len() as u64).write(writer)?;
for hops in self.paths.iter() {
hops.write(writer)?;
}
+ write_tlv_fields!(writer, {}, {});
Ok(())
}
}
impl Readable for Route {
fn read<R: ::std::io::Read>(reader: &mut R) -> Result<Route, DecodeError> {
+ let _ver = read_ver_prefix!(reader, SERIALIZATION_VERSION);
let path_count: u64 = Readable::read(reader)?;
let mut paths = Vec::with_capacity(cmp::min(path_count, 128) as usize);
for _ in 0..path_count {
paths.push(Readable::read(reader)?);
}
+ read_tlv_fields!(reader, {}, {});
Ok(Route { paths })
}
}
outbound_capacity_msat: 100000,
inbound_capacity_msat: 100000,
is_outbound: true, is_funding_locked: true,
- is_live: true, is_public: true,
+ is_usable: true, is_public: true,
counterparty_forwarding_info: None,
}];
outbound_capacity_msat: 250_000_000,
inbound_capacity_msat: 0,
is_outbound: true, is_funding_locked: true,
- is_live: true, is_public: true,
+ is_usable: true, is_public: true,
counterparty_forwarding_info: None,
}];
let route = get_route(&our_id, &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[2], None, Some(&our_chans.iter().collect::<Vec<_>>()), &Vec::new(), 100, 42, Arc::clone(&logger)).unwrap();
outbound_capacity_msat: 250_000_000,
inbound_capacity_msat: 0,
is_outbound: true, is_funding_locked: true,
- is_live: true, is_public: true,
+ is_usable: true, is_public: true,
counterparty_forwarding_info: None,
}];
let route = get_route(&our_id, &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[2], None, Some(&our_chans.iter().collect::<Vec<_>>()), &Vec::new(), 100, 42, Arc::clone(&logger)).unwrap();
outbound_capacity_msat: 250_000_000,
inbound_capacity_msat: 0,
is_outbound: true, is_funding_locked: true,
- is_live: true, is_public: true,
+ is_usable: true, is_public: true,
counterparty_forwarding_info: None,
}];
let route = get_route(&our_id, &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[2], None, Some(&our_chans.iter().collect::<Vec<_>>()), &Vec::new(), 100, 42, Arc::clone(&logger)).unwrap();
outbound_capacity_msat: 250_000_000,
inbound_capacity_msat: 0,
is_outbound: true, is_funding_locked: true,
- is_live: true, is_public: true,
+ is_usable: true, is_public: true,
counterparty_forwarding_info: None,
}];
let mut last_hops = last_hops(&nodes);
outbound_capacity_msat: 100000,
inbound_capacity_msat: 100000,
is_outbound: true, is_funding_locked: true,
- is_live: true, is_public: true,
+ is_usable: true, is_public: true,
counterparty_forwarding_info: None,
}];
let route = get_route(&source_node_id, &NetworkGraph::new(genesis_block(Network::Testnet).header.block_hash()), &target_node_id, None, Some(&our_chans.iter().collect::<Vec<_>>()), &last_hops.iter().collect::<Vec<_>>(), 100, 42, Arc::new(test_utils::TestLogger::new())).unwrap();
outbound_capacity_msat: 200_000_000,
inbound_capacity_msat: 0,
is_outbound: true, is_funding_locked: true,
- is_live: true, is_public: true,
+ is_usable: true, is_public: true,
counterparty_forwarding_info: None,
}];
pub(super) fn random_init_seed() -> u64 {
// Because the default HashMap in std pulls OS randomness, we can use it as a (bad) RNG.
- use std::hash::{BuildHasher, Hasher};
+ use core::hash::{BuildHasher, Hasher};
let seed = std::collections::hash_map::RandomState::new().build_hasher().finish();
println!("Using seed of {}", seed);
seed
let mut d = match get_route_file() {
Ok(f) => f,
Err(_) => {
- eprintln!("Please fetch https://bitcoin.ninja/ldk-net_graph-879e309c128-2020-02-12.bin and place it at lightning/net_graph-2021-02-12.bin");
+ eprintln!("Please fetch https://bitcoin.ninja/ldk-net_graph-05f0c5a0d772-2020-02-12.bin and place it at lightning/net_graph-2021-02-12.bin");
return;
},
};
let mut d = match get_route_file() {
Ok(f) => f,
Err(_) => {
- eprintln!("Please fetch https://bitcoin.ninja/ldk-net_graph-879e309c128-2020-02-12.bin and place it at lightning/net_graph-2021-02-12.bin");
+ eprintln!("Please fetch https://bitcoin.ninja/ldk-net_graph-05f0c5a0d772-2020-02-12.bin and place it at lightning/net_graph-2021-02-12.bin");
return;
},
};
#[bench]
fn generate_routes(bench: &mut Bencher) {
let mut d = tests::get_route_file()
- .expect("Please fetch https://bitcoin.ninja/ldk-net_graph-879e309c128-2020-02-12.bin and place it at lightning/net_graph-2021-02-12.bin");
+ .expect("Please fetch https://bitcoin.ninja/ldk-net_graph-05f0c5a0d772-2020-02-12.bin and place it at lightning/net_graph-2021-02-12.bin");
let graph = NetworkGraph::read(&mut d).unwrap();
// First, get 100 (source, destination) pairs for which route-getting actually succeeds...
#[bench]
fn generate_mpp_routes(bench: &mut Bencher) {
let mut d = tests::get_route_file()
- .expect("Please fetch https://bitcoin.ninja/ldk-net_graph-879e309c128-2020-02-12.bin and place it at lightning/net_graph-2021-02-12.bin");
+ .expect("Please fetch https://bitcoin.ninja/ldk-net_graph-05f0c5a0d772-2020-02-12.bin and place it at lightning/net_graph-2021-02-12.bin");
let graph = NetworkGraph::read(&mut d).unwrap();
// First, get 100 (source, destination) pairs for which route-getting actually succeeds...