This commit is contained in:
lbl
2026-02-24 16:08:44 +08:00
parent 4708ed2b16
commit ecdb359bbd
5 changed files with 11 additions and 7 deletions
+3 -1
View File
@@ -18,7 +18,9 @@ impl PacketCrypto {
pub(crate) fn new_from_str(s: Option<&str>) -> Self { pub(crate) fn new_from_str(s: Option<&str>) -> Self {
Self { Self {
crypto: s.map(chacha20_poly1305::PacketCrypto::new_from_str).map(Arc::new), crypto: s
.map(chacha20_poly1305::PacketCrypto::new_from_str)
.map(Arc::new),
} }
} }
pub(crate) fn encrypt_reserve(&self) -> usize { pub(crate) fn encrypt_reserve(&self) -> usize {
+4 -1
View File
@@ -68,7 +68,10 @@ impl P2pOutbound {
self.route_table.get_route_by_id(id).ok() self.route_table.get_route_by_id(id).ok()
} }
pub fn get_p2p_route_by_id(&self, id: &Ipv4Addr) -> Option<Route> { pub fn get_p2p_route_by_id(&self, id: &Ipv4Addr) -> Option<Route> {
self.route_table.get_route_by_id(id).ok().filter(|v| v.is_direct()) self.route_table
.get_route_by_id(id)
.ok()
.filter(|v| v.is_direct())
} }
pub fn exists_route_by_id(&self, id: &Ipv4Addr) -> bool { pub fn exists_route_by_id(&self, id: &Ipv4Addr) -> bool {
self.route_table.exists(id) self.route_table.exists(id)
+1 -2
View File
@@ -1,11 +1,10 @@
use parking_lot::{Mutex, RwLock}; use parking_lot::{Mutex, RwLock};
use rust_p2p_core::route::{RouteKey, DEFAULT_RTT}; use rust_p2p_core::route::{DEFAULT_RTT, RouteKey};
use std::collections::HashMap; use std::collections::HashMap;
use std::net::Ipv4Addr; use std::net::Ipv4Addr;
use std::sync::Arc; use std::sync::Arc;
use std::time::Instant; use std::time::Instant;
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct Route { pub struct Route {
route_key: RouteKey, route_key: RouteKey,