X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Frouting%2Fscoring.rs;h=77e1a13065201bd9e705db19e795fb6640fe2fed;hb=21eeca4adde98c91267291bd49c8d4ee423776b5;hp=bb043164a0e8895f8bbe95c8d0f50b7025d8365b;hpb=dedc8306f68e397dd51d0e9055eab2c04e373cdf;p=rust-lightning diff --git a/lightning/src/routing/scoring.rs b/lightning/src/routing/scoring.rs index bb043164..77e1a130 100644 --- a/lightning/src/routing/scoring.rs +++ b/lightning/src/routing/scoring.rs @@ -64,7 +64,6 @@ use crate::util::logger::Logger; use crate::prelude::*; use core::{cmp, fmt}; -use core::convert::TryInto; use core::ops::{Deref, DerefMut}; use core::time::Duration; use crate::io::{self, Read}; @@ -2153,7 +2152,7 @@ impl Readable for ChannelLiquidity { #[cfg(test)] mod tests { use super::{ChannelLiquidity, HistoricalBucketRangeTracker, ProbabilisticScoringFeeParameters, ProbabilisticScoringDecayParameters, ProbabilisticScorer}; - use crate::blinded_path::{BlindedHop, BlindedPath}; + use crate::blinded_path::{BlindedHop, BlindedPath, IntroductionNode}; use crate::util::config::UserConfig; use crate::ln::channelmanager; @@ -2167,7 +2166,7 @@ mod tests { use bitcoin::blockdata::constants::ChainHash; use bitcoin::hashes::Hash; use bitcoin::hashes::sha256d::Hash as Sha256dHash; - use bitcoin::network::constants::Network; + use bitcoin::network::Network; use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey}; use core::time::Duration; use crate::io; @@ -3568,7 +3567,7 @@ mod tests { let mut path = payment_path_for_amount(768); let recipient_hop = path.hops.pop().unwrap(); let blinded_path = BlindedPath { - introduction_node_id: path.hops.last().as_ref().unwrap().pubkey, + introduction_node: IntroductionNode::NodeId(path.hops.last().as_ref().unwrap().pubkey), blinding_point: test_utils::pubkey(42), blinded_hops: vec![ BlindedHop { blinded_node_id: test_utils::pubkey(44), encrypted_payload: Vec::new() } @@ -3684,44 +3683,7 @@ pub mod benches { pub fn decay_100k_channel_bounds(bench: &mut Criterion) { let logger = TestLogger::new(); - let network_graph = bench_utils::read_network_graph(&logger).unwrap(); - let mut scorer = ProbabilisticScorer::new(Default::default(), &network_graph, &logger); - // Score a number of random channels - let mut seed: u64 = 0xdeadbeef; - for _ in 0..100_000 { - seed = seed.overflowing_mul(6364136223846793005).0.overflowing_add(1).0; - let (victim, victim_dst, amt) = { - let rong = network_graph.read_only(); - let channels = rong.channels(); - let chan = channels.unordered_iter() - .skip((seed as usize) % channels.len()) - .next().unwrap(); - seed = seed.overflowing_mul(6364136223846793005).0.overflowing_add(1).0; - let amt = seed % chan.1.capacity_sats.map(|c| c * 1000) - .or(chan.1.one_to_two.as_ref().map(|info| info.htlc_maximum_msat)) - .or(chan.1.two_to_one.as_ref().map(|info| info.htlc_maximum_msat)) - .unwrap_or(1_000_000_000).saturating_add(1); - (*chan.0, chan.1.node_two, amt) - }; - let path = Path { - hops: vec![RouteHop { - pubkey: victim_dst.as_pubkey().unwrap(), - node_features: NodeFeatures::empty(), - short_channel_id: victim, - channel_features: ChannelFeatures::empty(), - fee_msat: amt, - cltv_expiry_delta: 42, - maybe_announced_channel: true, - }], - blinded_tail: None - }; - seed = seed.overflowing_mul(6364136223846793005).0.overflowing_add(1).0; - if seed % 1 == 0 { - scorer.probe_failed(&path, victim, Duration::ZERO); - } else { - scorer.probe_successful(&path, Duration::ZERO); - } - } + let (network_graph, mut scorer) = bench_utils::read_graph_scorer(&logger).unwrap(); let mut cur_time = Duration::ZERO; cur_time += Duration::from_millis(1); scorer.time_passed(cur_time);