827c13b69e
dont build netstack in CI additional rust 2024 fixes fixes removed temp.rs first round of cleanup removed duplicated NS types moved gateway probe to the monorepo
22 lines
695 B
Rust
22 lines
695 B
Rust
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
use nym_sphinx_types::{Delay, delays};
|
|
use std::time::Duration;
|
|
use thiserror::Error;
|
|
|
|
#[derive(Debug, Error, Clone, Copy)]
|
|
#[error("the route vector contains {available} nodes while {requested} hops are required")]
|
|
pub struct InvalidNumberOfHops {
|
|
available: usize,
|
|
requested: u8,
|
|
}
|
|
|
|
pub fn generate_hop_delays(average_packet_delay: Duration, num_hops: usize) -> Vec<Delay> {
|
|
if average_packet_delay.is_zero() {
|
|
vec![nym_sphinx_types::Delay::new_from_millis(0); num_hops]
|
|
} else {
|
|
delays::generate_from_average_duration(num_hops, average_packet_delay)
|
|
}
|
|
}
|