From 74e2f9a2c0cb00c14e62d2d015aa494f6b7bdd5c Mon Sep 17 00:00:00 2001 From: Christien Rioux Date: Fri, 27 Oct 2023 16:12:58 -0400 Subject: [PATCH] cleanup visibility --- veilid-core/src/attachment_manager.rs | 3 - veilid-core/src/core_context.rs | 1 - .../src/network_manager/connection_handle.rs | 25 ++-- .../src/network_manager/connection_manager.rs | 4 - veilid-core/src/network_manager/native/mod.rs | 4 - .../network_manager/native/protocol/mod.rs | 10 +- .../src/network_manager/network_connection.rs | 36 +++--- .../src/network_manager/receipt_manager.rs | 5 + veilid-core/src/network_manager/stats.rs | 2 +- .../src/network_manager/types/address.rs | 14 +-- .../network_manager/types/dial_info/mod.rs | 2 + .../types/low_level_protocol_type.rs | 12 +- veilid-core/src/network_manager/wasm/mod.rs | 6 +- .../src/network_manager/wasm/protocol/mod.rs | 12 +- .../src/network_manager/wasm/protocol/ws.rs | 2 +- veilid-core/src/routing_table/bucket_entry.rs | 11 +- veilid-core/src/routing_table/mod.rs | 116 ++---------------- veilid-core/src/routing_table/node_ref.rs | 12 +- .../src/routing_table/node_ref_filter.rs | 3 + veilid-core/src/routing_table/privacy.rs | 8 -- .../src/routing_table/route_spec_store/mod.rs | 22 ++-- .../remote_private_route_info.rs | 2 +- .../route_spec_store/route_set_spec_detail.rs | 12 +- .../route_spec_store_cache.rs | 4 +- .../route_spec_store_content.rs | 2 +- .../route_spec_store/route_stats.rs | 3 +- .../routing_table/routing_domain_editor.rs | 2 +- .../src/routing_table/routing_domains.rs | 7 +- .../src/routing_table/routing_table_inner.rs | 36 ++---- .../src/routing_table/tasks/ping_validator.rs | 6 +- .../src/rpc_processor/coders/address.rs | 4 +- .../rpc_processor/coders/address_type_set.rs | 4 +- .../src/rpc_processor/coders/dial_info.rs | 6 +- .../rpc_processor/coders/dial_info_class.rs | 8 +- .../rpc_processor/coders/dial_info_detail.rs | 4 +- .../src/rpc_processor/coders/key256.rs | 4 +- veilid-core/src/rpc_processor/coders/mod.rs | 37 +++--- .../rpc_processor/coders/operations/mod.rs | 44 +++---- .../coders/operations/operation_route.rs | 4 +- .../coders/operations/operation_status.rs | 4 +- .../operation_validate_dial_info.rs | 2 +- .../operations/operation_value_changed.rs | 2 +- veilid-core/src/rpc_processor/destination.rs | 2 +- veilid-core/src/rpc_processor/fanout_call.rs | 10 +- veilid-core/src/rpc_processor/fanout_queue.rs | 2 +- veilid-core/src/rpc_processor/mod.rs | 33 ++--- veilid-core/src/rpc_processor/rpc_route.rs | 5 +- veilid-core/src/rpc_processor/rpc_status.rs | 7 +- veilid-core/src/storage_manager/mod.rs | 2 +- 49 files changed, 207 insertions(+), 361 deletions(-) diff --git a/veilid-core/src/attachment_manager.rs b/veilid-core/src/attachment_manager.rs index 2faecd45..feb0ee69 100644 --- a/veilid-core/src/attachment_manager.rs +++ b/veilid-core/src/attachment_manager.rs @@ -28,7 +28,6 @@ impl AttachmentManager { fn new_unlocked_inner( config: VeilidConfig, storage_manager: StorageManager, - protected_store: ProtectedStore, table_store: TableStore, #[cfg(feature = "unstable-blockstore")] block_store: BlockStore, crypto: Crypto, @@ -58,7 +57,6 @@ impl AttachmentManager { pub fn new( config: VeilidConfig, storage_manager: StorageManager, - protected_store: ProtectedStore, table_store: TableStore, #[cfg(feature = "unstable-blockstore")] block_store: BlockStore, crypto: Crypto, @@ -68,7 +66,6 @@ impl AttachmentManager { unlocked_inner: Arc::new(Self::new_unlocked_inner( config, storage_manager, - protected_store, table_store, #[cfg(feature = "unstable-blockstore")] block_store, diff --git a/veilid-core/src/core_context.rs b/veilid-core/src/core_context.rs index 740ce812..e8f79ab3 100644 --- a/veilid-core/src/core_context.rs +++ b/veilid-core/src/core_context.rs @@ -140,7 +140,6 @@ impl ServicesContext { let attachment_manager = AttachmentManager::new( self.config.clone(), storage_manager, - protected_store, table_store, #[cfg(feature = "unstable-blockstore")] block_store, diff --git a/veilid-core/src/network_manager/connection_handle.rs b/veilid-core/src/network_manager/connection_handle.rs index 2f960f65..bbc7dff5 100644 --- a/veilid-core/src/network_manager/connection_handle.rs +++ b/veilid-core/src/network_manager/connection_handle.rs @@ -2,7 +2,7 @@ use super::*; #[derive(Clone, Debug)] pub struct ConnectionHandle { - id: NetworkConnectionId, + _id: NetworkConnectionId, descriptor: ConnectionDescriptor, channel: flume::Sender<(Option, Vec)>, } @@ -20,27 +20,28 @@ impl ConnectionHandle { channel: flume::Sender<(Option, Vec)>, ) -> Self { Self { - id, + _id: id, descriptor, channel, } } - pub fn connection_id(&self) -> NetworkConnectionId { - self.id - } + // pub fn connection_id(&self) -> NetworkConnectionId { + // self.id + // } pub fn connection_descriptor(&self) -> ConnectionDescriptor { self.descriptor } - #[cfg_attr(feature="verbose-tracing", instrument(level="trace", skip(self, message), fields(message.len = message.len())))] - pub fn send(&self, message: Vec) -> ConnectionHandleSendResult { - match self.channel.send((Span::current().id(), message)) { - Ok(()) => ConnectionHandleSendResult::Sent, - Err(e) => ConnectionHandleSendResult::NotSent(e.0 .1), - } - } + // #[cfg_attr(feature="verbose-tracing", instrument(level="trace", skip(self, message), fields(message.len = message.len())))] + // pub fn send(&self, message: Vec) -> ConnectionHandleSendResult { + // match self.channel.send((Span::current().id(), message)) { + // Ok(()) => ConnectionHandleSendResult::Sent, + // Err(e) => ConnectionHandleSendResult::NotSent(e.0 .1), + // } + // } + #[cfg_attr(feature="verbose-tracing", instrument(level="trace", skip(self, message), fields(message.len = message.len())))] pub async fn send_async(&self, message: Vec) -> ConnectionHandleSendResult { match self diff --git a/veilid-core/src/network_manager/connection_manager.rs b/veilid-core/src/network_manager/connection_manager.rs index 361f16b3..4aabf0b0 100644 --- a/veilid-core/src/network_manager/connection_manager.rs +++ b/veilid-core/src/network_manager/connection_manager.rs @@ -84,10 +84,6 @@ impl ConnectionManager { self.arc.network_manager.clone() } - pub fn connection_initial_timeout_ms(&self) -> u32 { - self.arc.connection_initial_timeout_ms - } - pub fn connection_inactivity_timeout_ms(&self) -> u32 { self.arc.connection_inactivity_timeout_ms } diff --git a/veilid-core/src/network_manager/native/mod.rs b/veilid-core/src/network_manager/native/mod.rs index 89bd9fd1..5b2a07bb 100644 --- a/veilid-core/src/network_manager/native/mod.rs +++ b/veilid-core/src/network_manager/native/mod.rs @@ -690,10 +690,6 @@ impl Network { ///////////////////////////////////////////////////////////////// - pub fn get_protocol_config(&self) -> ProtocolConfig { - self.inner.lock().protocol_config.clone() - } - #[instrument(level = "debug", err, skip_all)] pub async fn startup(&self) -> EyreResult<()> { // initialize interfaces diff --git a/veilid-core/src/network_manager/native/protocol/mod.rs b/veilid-core/src/network_manager/native/protocol/mod.rs index b3a7e321..c59d87de 100644 --- a/veilid-core/src/network_manager/native/protocol/mod.rs +++ b/veilid-core/src/network_manager/native/protocol/mod.rs @@ -9,7 +9,7 @@ use std::io; #[derive(Debug)] pub(in crate::network_manager) enum ProtocolNetworkConnection { - Dummy(DummyNetworkConnection), + // Dummy(DummyNetworkConnection), RawTcp(tcp::RawTcpNetworkConnection), WsAccepted(ws::WebSocketNetworkConnectionAccepted), Ws(ws::WebsocketNetworkConnectionWS), @@ -47,7 +47,7 @@ impl ProtocolNetworkConnection { pub fn descriptor(&self) -> ConnectionDescriptor { match self { - Self::Dummy(d) => d.descriptor(), + // Self::Dummy(d) => d.descriptor(), Self::RawTcp(t) => t.descriptor(), Self::WsAccepted(w) => w.descriptor(), Self::Ws(w) => w.descriptor(), @@ -57,7 +57,7 @@ impl ProtocolNetworkConnection { pub async fn close(&self) -> io::Result> { match self { - Self::Dummy(d) => d.close(), + // Self::Dummy(d) => d.close(), Self::RawTcp(t) => t.close().await, Self::WsAccepted(w) => w.close().await, Self::Ws(w) => w.close().await, @@ -67,7 +67,7 @@ impl ProtocolNetworkConnection { pub async fn send(&self, message: Vec) -> io::Result> { match self { - Self::Dummy(d) => d.send(message), + // Self::Dummy(d) => d.send(message), Self::RawTcp(t) => t.send(message).await, Self::WsAccepted(w) => w.send(message).await, Self::Ws(w) => w.send(message).await, @@ -76,7 +76,7 @@ impl ProtocolNetworkConnection { } pub async fn recv(&self) -> io::Result>> { match self { - Self::Dummy(d) => d.recv(), + // Self::Dummy(d) => d.recv(), Self::RawTcp(t) => t.recv().await, Self::WsAccepted(w) => w.recv().await, Self::Ws(w) => w.recv().await, diff --git a/veilid-core/src/network_manager/network_connection.rs b/veilid-core/src/network_manager/network_connection.rs index 9be79652..158a8e7f 100644 --- a/veilid-core/src/network_manager/network_connection.rs +++ b/veilid-core/src/network_manager/network_connection.rs @@ -45,25 +45,25 @@ cfg_if::cfg_if! { /////////////////////////////////////////////////////////// // Dummy protocol network connection for testing -#[derive(Debug)] -pub struct DummyNetworkConnection { - descriptor: ConnectionDescriptor, -} +// #[derive(Debug)] +// pub struct DummyNetworkConnection { +// descriptor: ConnectionDescriptor, +// } -impl DummyNetworkConnection { - pub fn descriptor(&self) -> ConnectionDescriptor { - self.descriptor - } - pub fn close(&self) -> io::Result> { - Ok(NetworkResult::Value(())) - } - pub fn send(&self, _message: Vec) -> io::Result> { - Ok(NetworkResult::Value(())) - } - pub fn recv(&self) -> io::Result>> { - Ok(NetworkResult::Value(Vec::new())) - } -} +// impl DummyNetworkConnection { +// pub fn descriptor(&self) -> ConnectionDescriptor { +// self.descriptor +// } +// pub fn close(&self) -> io::Result> { +// Ok(NetworkResult::Value(())) +// } +// pub fn send(&self, _message: Vec) -> io::Result> { +// Ok(NetworkResult::Value(())) +// } +// pub fn recv(&self) -> io::Result>> { +// Ok(NetworkResult::Value(Vec::new())) +// } +// } /////////////////////////////////////////////////////////// // Top-level protocol independent network connection object diff --git a/veilid-core/src/network_manager/receipt_manager.rs b/veilid-core/src/network_manager/receipt_manager.rs index 8bf92d3c..09f456c6 100644 --- a/veilid-core/src/network_manager/receipt_manager.rs +++ b/veilid-core/src/network_manager/receipt_manager.rs @@ -7,6 +7,7 @@ use routing_table::*; use stop_token::future::FutureExt; #[derive(Clone, Debug)] +#[allow(dead_code)] pub(crate) enum ReceiptEvent { ReturnedOutOfBand, ReturnedInBand { inbound_noderef: NodeRef }, @@ -52,6 +53,7 @@ where type ReceiptCallbackType = Box; type ReceiptSingleShotType = SingleShotEventual; +#[allow(dead_code)] enum ReceiptRecordCallbackType { Normal(ReceiptCallbackType), SingleShot(Option), @@ -90,6 +92,7 @@ impl fmt::Debug for ReceiptRecord { } impl ReceiptRecord { + #[allow(dead_code)] pub fn new( receipt: Receipt, expiration_ts: Timestamp, @@ -314,6 +317,7 @@ impl ReceiptManager { debug!("finished receipt manager shutdown"); } + #[allow(dead_code)] pub fn record_receipt( &self, receipt: Receipt, @@ -369,6 +373,7 @@ impl ReceiptManager { inner.next_oldest_ts = new_next_oldest_ts; } + #[allow(dead_code)] pub async fn cancel_receipt(&self, nonce: &Nonce) -> EyreResult<()> { log_rpc!(debug "== Cancel Receipt {}", nonce.encode()); diff --git a/veilid-core/src/network_manager/stats.rs b/veilid-core/src/network_manager/stats.rs index f96da01d..b5296607 100644 --- a/veilid-core/src/network_manager/stats.rs +++ b/veilid-core/src/network_manager/stats.rs @@ -67,7 +67,7 @@ impl NetworkManager { .add_down(bytes); } - // Get stats + #[allow(dead_code)] pub fn get_stats(&self) -> NetworkManagerStats { let inner = self.inner.lock(); inner.stats.clone() diff --git a/veilid-core/src/network_manager/types/address.rs b/veilid-core/src/network_manager/types/address.rs index 6b0f510a..abd1702f 100644 --- a/veilid-core/src/network_manager/types/address.rs +++ b/veilid-core/src/network_manager/types/address.rs @@ -1,7 +1,6 @@ use super::*; // Ordering here matters, IPV6 is preferred to IPV4 in dial info sorts -// See issue #236 for eventual resolution of this unfortunate implementation #[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Ord, Eq, Hash, Serialize, Deserialize)] pub enum Address { IPV6(Ipv6Addr), @@ -21,6 +20,7 @@ impl Address { SocketAddr::V6(v6) => Address::IPV6(*v6.ip()), } } + #[cfg_attr(target_arch = "wasm32", allow(dead_code))] pub fn from_ip_addr(addr: IpAddr) -> Address { match addr { IpAddr::V4(v4) => Address::IPV4(v4), @@ -33,18 +33,6 @@ impl Address { Address::IPV6(_) => AddressType::IPV6, } } - pub fn address_string(&self) -> String { - match self { - Address::IPV4(v4) => v4.to_string(), - Address::IPV6(v6) => v6.to_string(), - } - } - pub fn address_string_with_port(&self, port: u16) -> String { - match self { - Address::IPV4(v4) => format!("{}:{}", v4, port), - Address::IPV6(v6) => format!("[{}]:{}", v6, port), - } - } pub fn is_unspecified(&self) -> bool { match self { Address::IPV4(v4) => ipv4addr_is_unspecified(v4), diff --git a/veilid-core/src/network_manager/types/dial_info/mod.rs b/veilid-core/src/network_manager/types/dial_info/mod.rs index e09d181e..4e948f5e 100644 --- a/veilid-core/src/network_manager/types/dial_info/mod.rs +++ b/veilid-core/src/network_manager/types/dial_info/mod.rs @@ -234,6 +234,7 @@ impl DialInfo { Self::WSS(di) => di.socket_address.address(), } } + #[allow(dead_code)] pub fn set_address(&mut self, address: Address) { match self { Self::UDP(di) => di.socket_address.set_address(address), @@ -453,6 +454,7 @@ impl DialInfo { } } } + #[allow(dead_code)] pub async fn to_url(&self) -> String { match self { DialInfo::UDP(di) => intf::ptr_lookup(di.socket_address.ip_addr()) diff --git a/veilid-core/src/network_manager/types/low_level_protocol_type.rs b/veilid-core/src/network_manager/types/low_level_protocol_type.rs index c9e96d3b..4492e858 100644 --- a/veilid-core/src/network_manager/types/low_level_protocol_type.rs +++ b/veilid-core/src/network_manager/types/low_level_protocol_type.rs @@ -4,18 +4,8 @@ use super::*; // Keep member order appropriate for sorting < preference // Must match DialInfo order -#[allow(clippy::derived_hash_with_manual_eq)] -#[derive(Debug, PartialOrd, Ord, Hash, EnumSetType, Serialize, Deserialize)] -#[enumset(repr = "u8")] +#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] pub enum LowLevelProtocolType { UDP = 0, TCP = 1, } - -impl LowLevelProtocolType { - pub fn is_connection_oriented(&self) -> bool { - matches!(self, LowLevelProtocolType::TCP) - } -} - -// pub type LowLevelProtocolTypeSet = EnumSet; diff --git a/veilid-core/src/network_manager/wasm/mod.rs b/veilid-core/src/network_manager/wasm/mod.rs index 565356e1..62ffce44 100644 --- a/veilid-core/src/network_manager/wasm/mod.rs +++ b/veilid-core/src/network_manager/wasm/mod.rs @@ -63,7 +63,7 @@ struct NetworkUnlockedInner { } #[derive(Clone)] -pub struct Network { +pub(in crate::network_manager) struct Network { config: VeilidConfig, inner: Arc>, unlocked_inner: Arc, @@ -459,10 +459,6 @@ impl Network { false } - pub fn get_protocol_config(&self) -> ProtocolConfig { - self.inner.lock().protocol_config.clone() - } - ////////////////////////////////////////// pub async fn tick(&self) -> EyreResult<()> { Ok(()) diff --git a/veilid-core/src/network_manager/wasm/protocol/mod.rs b/veilid-core/src/network_manager/wasm/protocol/mod.rs index 168486a6..44f77d20 100644 --- a/veilid-core/src/network_manager/wasm/protocol/mod.rs +++ b/veilid-core/src/network_manager/wasm/protocol/mod.rs @@ -5,9 +5,9 @@ use super::*; use std::io; #[derive(Debug)] -pub enum ProtocolNetworkConnection { +pub(in crate::network_manager) enum ProtocolNetworkConnection { #[allow(dead_code)] - Dummy(DummyNetworkConnection), + //Dummy(DummyNetworkConnection), Ws(ws::WebsocketNetworkConnection), //WebRTC(wrtc::WebRTCNetworkConnection), } @@ -37,26 +37,26 @@ impl ProtocolNetworkConnection { pub fn descriptor(&self) -> ConnectionDescriptor { match self { - Self::Dummy(d) => d.descriptor(), + // Self::Dummy(d) => d.descriptor(), Self::Ws(w) => w.descriptor(), } } pub async fn close(&self) -> io::Result> { match self { - Self::Dummy(d) => d.close(), + // Self::Dummy(d) => d.close(), Self::Ws(w) => w.close().await, } } pub async fn send(&self, message: Vec) -> io::Result> { match self { - Self::Dummy(d) => d.send(message), + // Self::Dummy(d) => d.send(message), Self::Ws(w) => w.send(message).await, } } pub async fn recv(&self) -> io::Result>> { match self { - Self::Dummy(d) => d.recv(), + // Self::Dummy(d) => d.recv(), Self::Ws(w) => w.recv().await, } } diff --git a/veilid-core/src/network_manager/wasm/protocol/ws.rs b/veilid-core/src/network_manager/wasm/protocol/ws.rs index 09cefda6..85fbb46d 100644 --- a/veilid-core/src/network_manager/wasm/protocol/ws.rs +++ b/veilid-core/src/network_manager/wasm/protocol/ws.rs @@ -117,7 +117,7 @@ impl WebsocketNetworkConnection { /////////////////////////////////////////////////////////// /// -pub struct WebsocketProtocolHandler {} +pub(in crate::network_manager) struct WebsocketProtocolHandler {} impl WebsocketProtocolHandler { #[instrument(level = "trace", ret, err)] diff --git a/veilid-core/src/routing_table/bucket_entry.rs b/veilid-core/src/routing_table/bucket_entry.rs index d76024ae..02a33d86 100644 --- a/veilid-core/src/routing_table/bucket_entry.rs +++ b/veilid-core/src/routing_table/bucket_entry.rs @@ -175,6 +175,7 @@ impl BucketEntryInner { } // Less is faster + #[allow(dead_code)] pub fn cmp_fastest(e1: &Self, e2: &Self) -> std::cmp::Ordering { // Lower latency to the front if let Some(e1_latency) = &e1.peer_stats.latency { @@ -234,6 +235,7 @@ impl BucketEntryInner { } } + #[allow(dead_code)] pub fn sort_fastest_reliable_fn(cur_ts: Timestamp) -> impl FnMut(&Self, &Self) -> std::cmp::Ordering { move |e1, e2| Self::cmp_fastest_reliable(cur_ts, e1, e2) } @@ -537,6 +539,7 @@ impl BucketEntryInner { self.envelope_support = envelope_support; } + #[allow(dead_code)] pub fn envelope_support(&self) -> Vec { self.envelope_support.clone() } @@ -617,12 +620,8 @@ impl BucketEntryInner { } } - pub fn set_updated_since_last_network_change(&mut self, updated: bool) { - self.updated_since_last_network_change = updated; - } - - pub fn has_updated_since_last_network_change(&self) -> bool { - self.updated_since_last_network_change + pub fn reset_updated_since_last_network_change(&mut self) { + self.updated_since_last_network_change = false; } ///// stats methods diff --git a/veilid-core/src/routing_table/mod.rs b/veilid-core/src/routing_table/mod.rs index db5283fb..da54619b 100644 --- a/veilid-core/src/routing_table/mod.rs +++ b/veilid-core/src/routing_table/mod.rs @@ -20,20 +20,20 @@ use super::*; use crate::crypto::*; use crate::network_manager::*; use crate::rpc_processor::*; + use bucket::*; use hashlink::LruCache; -pub use bucket_entry::*; -pub use debug::*; -pub use find_peers::*; -pub use node_ref::*; -pub use node_ref_filter::*; -pub use privacy::*; -pub use route_spec_store::*; -pub use routing_domain_editor::*; -pub use routing_domains::*; -pub use routing_table_inner::*; -pub use stats_accounting::*; +pub(crate) use bucket_entry::*; +pub(crate) use node_ref::*; +pub(crate) use node_ref_filter::*; +pub(crate) use privacy::*; +pub(crate) use route_spec_store::*; +pub(crate) use routing_domain_editor::*; +pub(crate) use routing_domains::*; +pub(crate) use routing_table_inner::*; +pub(crate) use stats_accounting::*; + pub use types::*; ////////////////////////////////////////////////////////////////////////// @@ -64,7 +64,7 @@ pub struct LowLevelPortInfo { pub low_level_protocol_ports: LowLevelProtocolPorts, pub protocol_to_port: ProtocolToPortMapping, } -pub type RoutingTableEntryFilter<'t> = +pub(crate) type RoutingTableEntryFilter<'t> = Box>) -> bool + Send + 't>; type SerializedBuckets = Vec>; @@ -487,24 +487,10 @@ impl RoutingTable { self.inner.read().relay_node_last_keepalive(domain) } - pub fn has_dial_info(&self, domain: RoutingDomain) -> bool { - self.inner.read().has_dial_info(domain) - } - pub fn dial_info_details(&self, domain: RoutingDomain) -> Vec { self.inner.read().dial_info_details(domain) } - pub fn first_filtered_dial_info_detail( - &self, - routing_domain_set: RoutingDomainSet, - filter: &DialInfoFilter, - ) -> Option { - self.inner - .read() - .first_filtered_dial_info_detail(routing_domain_set, filter) - } - pub fn all_filtered_dial_info_details( &self, routing_domain_set: RoutingDomainSet, @@ -521,16 +507,6 @@ impl RoutingTable { .ensure_dial_info_is_valid(domain, dial_info) } - pub fn node_info_is_valid_in_routing_domain( - &self, - routing_domain: RoutingDomain, - node_info: &NodeInfo, - ) -> bool { - self.inner - .read() - .node_info_is_valid_in_routing_domain(routing_domain, node_info) - } - pub fn signed_node_info_is_valid_in_routing_domain( &self, routing_domain: RoutingDomain, @@ -587,20 +563,6 @@ impl RoutingTable { self.inner.read().get_network_class(routing_domain) } - /// Return the domain's filter for what we can receivein the form of a dial info filter - pub fn get_inbound_dial_info_filter(&self, routing_domain: RoutingDomain) -> DialInfoFilter { - self.inner - .read() - .get_inbound_dial_info_filter(routing_domain) - } - - /// Return the domain's filter for what we can receive in the form of a node ref filter - pub fn get_inbound_node_ref_filter(&self, routing_domain: RoutingDomain) -> NodeRefFilter { - self.inner - .read() - .get_inbound_node_ref_filter(routing_domain) - } - /// Return the domain's filter for what we can send out in the form of a dial info filter pub fn get_outbound_dial_info_filter(&self, routing_domain: RoutingDomain) -> DialInfoFilter { self.inner @@ -625,27 +587,7 @@ impl RoutingTable { self.inner.write().purge_last_connections(); } - pub fn get_entry_count( - &self, - routing_domain_set: RoutingDomainSet, - min_state: BucketEntryState, - crypto_kinds: &[CryptoKind], - ) -> usize { - self.inner - .read() - .get_entry_count(routing_domain_set, min_state, crypto_kinds) - } - - pub fn get_entry_count_per_crypto_kind( - &self, - routing_domain_set: RoutingDomainSet, - min_state: BucketEntryState, - ) -> BTreeMap { - self.inner - .read() - .get_entry_count_per_crypto_kind(routing_domain_set, min_state) - } - + /// See which nodes need to be pinged pub fn get_nodes_needing_ping( &self, routing_domain: RoutingDomain, @@ -656,11 +598,6 @@ impl RoutingTable { .get_nodes_needing_ping(self.clone(), routing_domain, cur_ts) } - pub fn get_all_nodes(&self, cur_ts: Timestamp) -> Vec { - let inner = self.inner.read(); - inner.get_all_nodes(self.clone(), cur_ts) - } - fn queue_bucket_kicks(&self, node_ids: TypedKeyGroup) { for node_id in node_ids.iter() { // Skip node ids we didn't add to buckets @@ -780,12 +717,6 @@ impl RoutingTable { out } - pub fn touch_recent_peer(&self, node_id: TypedKey, last_connection: ConnectionDescriptor) { - self.inner - .write() - .touch_recent_peer(node_id, last_connection) - } - ////////////////////////////////////////////////////////////////////// // Find Nodes @@ -984,27 +915,6 @@ impl RoutingTable { out } - pub fn find_peers_with_sort_and_filter( - &self, - node_count: usize, - cur_ts: Timestamp, - filters: VecDeque, - compare: C, - transform: T, - ) -> Vec - where - C: for<'a, 'b> FnMut( - &'a RoutingTableInner, - &'b Option>, - &'b Option>, - ) -> core::cmp::Ordering, - T: for<'r> FnMut(&'r RoutingTableInner, Option>) -> O + Send, - { - self.inner - .read() - .find_peers_with_sort_and_filter(node_count, cur_ts, filters, compare, transform) - } - pub fn find_preferred_fastest_nodes<'a, T, O>( &self, node_count: usize, diff --git a/veilid-core/src/routing_table/node_ref.rs b/veilid-core/src/routing_table/node_ref.rs index 2c4422ca..d7993c1a 100644 --- a/veilid-core/src/routing_table/node_ref.rs +++ b/veilid-core/src/routing_table/node_ref.rs @@ -112,12 +112,6 @@ pub(crate) trait NodeRefBase: Sized { fn best_node_id(&self) -> TypedKey { self.operate(|_rti, e| e.best_node_id()) } - fn has_updated_since_last_network_change(&self) -> bool { - self.operate(|_rti, e| e.has_updated_since_last_network_change()) - } - fn set_updated_since_last_network_change(&self) { - self.operate_mut(|_rti, e| e.set_updated_since_last_network_change(true)); - } fn update_node_status(&self, routing_domain: RoutingDomain, node_status: NodeStatus) { self.operate_mut(|_rti, e| { e.update_node_status(routing_domain, node_status); @@ -583,9 +577,9 @@ impl<'a> NodeRefLockedMut<'a> { } } - pub fn unlocked(&self) -> NodeRef { - self.nr.clone() - } + // pub fn unlocked(&self) -> NodeRef { + // self.nr.clone() + // } } impl<'a> NodeRefBase for NodeRefLockedMut<'a> { diff --git a/veilid-core/src/routing_table/node_ref_filter.rs b/veilid-core/src/routing_table/node_ref_filter.rs index 9c4d44cb..2950e3f9 100644 --- a/veilid-core/src/routing_table/node_ref_filter.rs +++ b/veilid-core/src/routing_table/node_ref_filter.rs @@ -35,6 +35,7 @@ impl NodeRefFilter { self.dial_info_filter = self.dial_info_filter.with_protocol_type(protocol_type); self } + #[allow(dead_code)] pub fn with_protocol_type_set(mut self, protocol_set: ProtocolTypeSet) -> Self { self.dial_info_filter = self.dial_info_filter.with_protocol_type_set(protocol_set); self @@ -43,6 +44,7 @@ impl NodeRefFilter { self.dial_info_filter = self.dial_info_filter.with_address_type(address_type); self } + #[allow(dead_code)] pub fn with_address_type_set(mut self, address_set: AddressTypeSet) -> Self { self.dial_info_filter = self.dial_info_filter.with_address_type_set(address_set); self @@ -54,6 +56,7 @@ impl NodeRefFilter { .filtered(&other_filter.dial_info_filter); self } + #[allow(dead_code)] pub fn is_dead(&self) -> bool { self.dial_info_filter.is_dead() || self.routing_domain_set.is_empty() } diff --git a/veilid-core/src/routing_table/privacy.rs b/veilid-core/src/routing_table/privacy.rs index 5a0e1391..e2926823 100644 --- a/veilid-core/src/routing_table/privacy.rs +++ b/veilid-core/src/routing_table/privacy.rs @@ -121,14 +121,6 @@ pub(crate) struct PrivateRoute { } impl PrivateRoute { - /// Empty private route is the form used when receiving the last hop - pub fn new_empty(public_key: TypedKey) -> Self { - Self { - public_key, - hop_count: 0, - hops: PrivateRouteHops::Empty, - } - } /// Stub route is the form used when no privacy is required, but you need to specify the destination for a safety route pub fn new_stub(public_key: TypedKey, node: RouteNode) -> Self { Self { diff --git a/veilid-core/src/routing_table/route_spec_store/mod.rs b/veilid-core/src/routing_table/route_spec_store/mod.rs index 8ea57eb9..035df5d9 100644 --- a/veilid-core/src/routing_table/route_spec_store/mod.rs +++ b/veilid-core/src/routing_table/route_spec_store/mod.rs @@ -1,4 +1,5 @@ use super::*; +use crate::veilid_api::*; mod permutation; mod remote_private_route_info; @@ -7,15 +8,14 @@ mod route_spec_store_cache; mod route_spec_store_content; mod route_stats; -pub use remote_private_route_info::*; -pub use route_set_spec_detail::*; -pub use route_spec_store_cache::*; -pub use route_spec_store_content::*; -pub use route_stats::*; - -use crate::veilid_api::*; - use permutation::*; +use remote_private_route_info::*; +use route_set_spec_detail::*; +use route_spec_store_cache::*; +use route_spec_store_content::*; + +pub(crate) use route_spec_store_cache::CompiledRoute; +pub(crate) use route_stats::*; /// The size of the remote private route cache const REMOTE_PRIVATE_ROUTE_CACHE_SIZE: usize = 1024; @@ -27,14 +27,14 @@ const ROUTE_MIN_IDLE_TIME_MS: u32 = 30_000; const COMPILED_ROUTE_CACHE_SIZE: usize = 256; #[derive(Debug)] -pub struct RouteSpecStoreInner { +struct RouteSpecStoreInner { /// Serialize RouteSpecStore content content: RouteSpecStoreContent, /// RouteSpecStore cache cache: RouteSpecStoreCache, } -pub struct RouteSpecStoreUnlockedInner { +struct RouteSpecStoreUnlockedInner { /// Handle to routing table routing_table: RoutingTable, /// Maximum number of hops in a route @@ -54,7 +54,7 @@ impl fmt::Debug for RouteSpecStoreUnlockedInner { /// The routing table's storage for private/safety routes #[derive(Clone, Debug)] -pub struct RouteSpecStore { +pub(crate) struct RouteSpecStore { inner: Arc>, unlocked_inner: Arc, } diff --git a/veilid-core/src/routing_table/route_spec_store/remote_private_route_info.rs b/veilid-core/src/routing_table/route_spec_store/remote_private_route_info.rs index 58270ade..2174daa8 100644 --- a/veilid-core/src/routing_table/route_spec_store/remote_private_route_info.rs +++ b/veilid-core/src/routing_table/route_spec_store/remote_private_route_info.rs @@ -2,7 +2,7 @@ use super::*; /// What remote private routes have seen #[derive(Debug, Clone, Default)] -pub struct RemotePrivateRouteInfo { +pub(crate) struct RemotePrivateRouteInfo { /// The private routes themselves private_routes: Vec, /// Did this remote private route see our node info due to no safety route in use diff --git a/veilid-core/src/routing_table/route_spec_store/route_set_spec_detail.rs b/veilid-core/src/routing_table/route_spec_store/route_set_spec_detail.rs index c41bb92b..11887352 100644 --- a/veilid-core/src/routing_table/route_spec_store/route_set_spec_detail.rs +++ b/veilid-core/src/routing_table/route_spec_store/route_set_spec_detail.rs @@ -1,7 +1,7 @@ use super::*; #[derive(Clone, Debug, Serialize, Deserialize)] -pub struct RouteSpecDetail { +pub(crate) struct RouteSpecDetail { /// Crypto kind pub crypto_kind: CryptoKind, /// Secret key @@ -11,7 +11,7 @@ pub struct RouteSpecDetail { } #[derive(Clone, Debug, Serialize, Deserialize)] -pub struct RouteSetSpecDetail { +pub(crate) struct RouteSetSpecDetail { /// Route set per crypto kind route_set: BTreeMap, /// Route noderefs @@ -53,9 +53,6 @@ impl RouteSetSpecDetail { pub fn get_route_by_key(&self, key: &PublicKey) -> Option<&RouteSpecDetail> { self.route_set.get(key) } - pub fn get_route_by_key_mut(&mut self, key: &PublicKey) -> Option<&mut RouteSpecDetail> { - self.route_set.get_mut(key) - } pub fn get_route_set_keys(&self) -> TypedKeyGroup { let mut tks = TypedKeyGroup::new(); for (k, v) in &self.route_set { @@ -74,11 +71,6 @@ impl RouteSetSpecDetail { ) -> alloc::collections::btree_map::Iter { self.route_set.iter() } - pub fn iter_route_set_mut( - &mut self, - ) -> alloc::collections::btree_map::IterMut { - self.route_set.iter_mut() - } pub fn get_stats(&self) -> &RouteStats { &self.stats } diff --git a/veilid-core/src/routing_table/route_spec_store/route_spec_store_cache.rs b/veilid-core/src/routing_table/route_spec_store/route_spec_store_cache.rs index e7e44bbf..6f303864 100644 --- a/veilid-core/src/routing_table/route_spec_store/route_spec_store_cache.rs +++ b/veilid-core/src/routing_table/route_spec_store/route_spec_store_cache.rs @@ -9,7 +9,7 @@ struct CompiledRouteCacheKey { /// Compiled route (safety route + private route) #[derive(Clone, Debug)] -pub struct CompiledRoute { +pub(crate) struct CompiledRoute { /// The safety route attached to the private route pub safety_route: SafetyRoute, /// The secret used to encrypt the message payload @@ -20,7 +20,7 @@ pub struct CompiledRoute { /// Ephemeral data used to help the RouteSpecStore operate efficiently #[derive(Debug)] -pub struct RouteSpecStoreCache { +pub(super) struct RouteSpecStoreCache { /// How many times nodes have been used used_nodes: HashMap, /// How many times nodes have been used at the terminal point of a route diff --git a/veilid-core/src/routing_table/route_spec_store/route_spec_store_content.rs b/veilid-core/src/routing_table/route_spec_store/route_spec_store_content.rs index d41a70fa..604ac9a2 100644 --- a/veilid-core/src/routing_table/route_spec_store/route_spec_store_content.rs +++ b/veilid-core/src/routing_table/route_spec_store/route_spec_store_content.rs @@ -2,7 +2,7 @@ use super::*; /// The core representation of the RouteSpecStore that can be serialized #[derive(Debug, Clone, Default, Serialize, Deserialize)] -pub struct RouteSpecStoreContent { +pub(super) struct RouteSpecStoreContent { /// All of the route sets we have allocated so far indexed by key id_by_key: HashMap, /// All of the route sets we have allocated so far diff --git a/veilid-core/src/routing_table/route_spec_store/route_stats.rs b/veilid-core/src/routing_table/route_spec_store/route_stats.rs index ad7bdf70..c8d390c7 100644 --- a/veilid-core/src/routing_table/route_spec_store/route_stats.rs +++ b/veilid-core/src/routing_table/route_spec_store/route_stats.rs @@ -1,7 +1,7 @@ use super::*; #[derive(Clone, Debug, Default, Serialize, Deserialize)] -pub struct RouteStats { +pub(crate) struct RouteStats { /// Consecutive failed to send count #[serde(skip)] pub failed_to_send: u32, @@ -94,6 +94,7 @@ impl RouteStats { } /// Get the transfer stats + #[allow(dead_code)] pub fn transfer_stats(&self) -> &TransferStatsDownUp { &self.transfer_stats_down_up } diff --git a/veilid-core/src/routing_table/routing_domain_editor.rs b/veilid-core/src/routing_table/routing_domain_editor.rs index 63eed645..6b50efbc 100644 --- a/veilid-core/src/routing_table/routing_domain_editor.rs +++ b/veilid-core/src/routing_table/routing_domain_editor.rs @@ -27,7 +27,7 @@ enum RoutingDomainChange { }, } -pub struct RoutingDomainEditor { +pub(crate) struct RoutingDomainEditor { routing_table: RoutingTable, routing_domain: RoutingDomain, changes: Vec, diff --git a/veilid-core/src/routing_table/routing_domains.rs b/veilid-core/src/routing_table/routing_domains.rs index 3139ca1b..ae5f0ed7 100644 --- a/veilid-core/src/routing_table/routing_domains.rs +++ b/veilid-core/src/routing_table/routing_domains.rs @@ -2,7 +2,7 @@ use super::*; /// Mechanism required to contact another node #[derive(Clone, Debug)] -pub enum ContactMethod { +pub(crate) enum ContactMethod { /// Node is not reachable by any means Unreachable, /// Connection should have already existed @@ -20,7 +20,7 @@ pub enum ContactMethod { } #[derive(Debug)] -pub struct RoutingDomainDetailCommon { +pub(crate) struct RoutingDomainDetailCommon { routing_domain: RoutingDomain, network_class: Option, outbound_protocols: ProtocolTypeSet, @@ -216,6 +216,7 @@ impl RoutingDomainDetailCommon { f(cpi.as_ref().unwrap()) } + #[allow(dead_code)] pub fn inbound_dial_info_filter(&self) -> DialInfoFilter { DialInfoFilter::all() .with_protocol_type_set(self.inbound_protocols) @@ -233,7 +234,7 @@ impl RoutingDomainDetailCommon { } /// General trait for all routing domains -pub trait RoutingDomainDetail { +pub(crate) trait RoutingDomainDetail { // Common accessors fn common(&self) -> &RoutingDomainDetailCommon; fn common_mut(&mut self) -> &mut RoutingDomainDetailCommon; diff --git a/veilid-core/src/routing_table/routing_table_inner.rs b/veilid-core/src/routing_table/routing_table_inner.rs index 661f91ac..4ab370cf 100644 --- a/veilid-core/src/routing_table/routing_table_inner.rs +++ b/veilid-core/src/routing_table/routing_table_inner.rs @@ -102,6 +102,7 @@ impl RoutingTableInner { self.with_routing_domain(domain, |rd| rd.common().relay_node_last_keepalive()) } + #[allow(dead_code)] pub fn has_dial_info(&self, domain: RoutingDomain) -> bool { self.with_routing_domain(domain, |rd| !rd.common().dial_info_details().is_empty()) } @@ -233,7 +234,7 @@ impl RoutingTableInner { let cur_ts = get_aligned_timestamp(); self.with_entries_mut(cur_ts, BucketEntryState::Dead, |rti, v| { v.with_mut(rti, |_rti, e| { - e.set_updated_since_last_network_change(false) + e.reset_updated_since_last_network_change(); }); Option::<()>::None }); @@ -265,6 +266,7 @@ impl RoutingTableInner { } /// Return the domain's filter for what we can receivein the form of a dial info filter + #[allow(dead_code)] pub fn get_inbound_dial_info_filter(&self, routing_domain: RoutingDomain) -> DialInfoFilter { self.with_routing_domain(routing_domain, |rdd| { rdd.common().inbound_dial_info_filter() @@ -272,6 +274,7 @@ impl RoutingTableInner { } /// Return the domain's filter for what we can receive in the form of a node ref filter + #[allow(dead_code)] pub fn get_inbound_node_ref_filter(&self, routing_domain: RoutingDomain) -> NodeRefFilter { let dif = self.get_inbound_dial_info_filter(routing_domain); NodeRefFilter::new() @@ -336,7 +339,7 @@ impl RoutingTableInner { self.with_entries_mut(cur_ts, BucketEntryState::Dead, |rti, e| { e.with_mut(rti, |_rti, e| { e.clear_signed_node_info(RoutingDomain::LocalNetwork); - e.set_updated_since_last_network_change(false); + e.reset_updated_since_last_network_change(); }); Option::<()>::None }); @@ -462,32 +465,6 @@ impl RoutingTableInner { count } - /// Count entries per crypto kind that match some criteria - pub fn get_entry_count_per_crypto_kind( - &self, - routing_domain_set: RoutingDomainSet, - min_state: BucketEntryState, - ) -> BTreeMap { - let mut counts = BTreeMap::new(); - let cur_ts = get_aligned_timestamp(); - self.with_entries(cur_ts, min_state, |rti, e| { - if let Some(crypto_kinds) = e.with_inner(|e| { - if e.best_routing_domain(rti, routing_domain_set).is_some() { - Some(e.crypto_kinds()) - } else { - None - } - }) { - // Got crypto kinds, add to map - for ck in crypto_kinds { - counts.entry(ck).and_modify(|x| *x += 1).or_insert(1); - } - } - Option::<()>::None - }); - counts - } - /// Iterate entries with a filter pub fn with_entries) -> Option>( &self, @@ -527,7 +504,7 @@ impl RoutingTableInner { None } - pub fn get_nodes_needing_ping( + pub(super) fn get_nodes_needing_ping( &self, outer_self: RoutingTable, routing_domain: RoutingDomain, @@ -575,6 +552,7 @@ impl RoutingTableInner { node_refs } + #[allow(dead_code)] pub fn get_all_nodes(&self, outer_self: RoutingTable, cur_ts: Timestamp) -> Vec { let mut node_refs = Vec::::with_capacity(self.bucket_entry_count()); self.with_entries(cur_ts, BucketEntryState::Unreliable, |_rti, entry| { diff --git a/veilid-core/src/routing_table/tasks/ping_validator.rs b/veilid-core/src/routing_table/tasks/ping_validator.rs index c6668779..7a3070d0 100644 --- a/veilid-core/src/routing_table/tasks/ping_validator.rs +++ b/veilid-core/src/routing_table/tasks/ping_validator.rs @@ -109,10 +109,8 @@ impl RoutingTable { unord.push( async move { - let out = rpc - .rpc_call_status(Destination::direct(relay_nr_filtered), true) - .await; - out + rpc.rpc_call_status(Destination::direct(relay_nr_filtered), true) + .await } .instrument(Span::current()) .boxed(), diff --git a/veilid-core/src/rpc_processor/coders/address.rs b/veilid-core/src/rpc_processor/coders/address.rs index 7e18ac02..370b4413 100644 --- a/veilid-core/src/rpc_processor/coders/address.rs +++ b/veilid-core/src/rpc_processor/coders/address.rs @@ -1,7 +1,7 @@ use super::*; use core::convert::TryInto; -pub fn encode_address( +pub(crate) fn encode_address( address: &Address, builder: &mut veilid_capnp::address::Builder, ) -> Result<(), RPCError> { @@ -37,7 +37,7 @@ pub fn encode_address( Ok(()) } -pub fn decode_address(reader: &veilid_capnp::address::Reader) -> Result { +pub(crate) fn decode_address(reader: &veilid_capnp::address::Reader) -> Result { match reader.reborrow().which() { Ok(veilid_capnp::address::Which::Ipv4(Ok(v4))) => { let v4b = v4.get_addr().to_be_bytes(); diff --git a/veilid-core/src/rpc_processor/coders/address_type_set.rs b/veilid-core/src/rpc_processor/coders/address_type_set.rs index f341d980..a9cec2aa 100644 --- a/veilid-core/src/rpc_processor/coders/address_type_set.rs +++ b/veilid-core/src/rpc_processor/coders/address_type_set.rs @@ -1,6 +1,6 @@ use super::*; -pub fn encode_address_type_set( +pub(crate) fn encode_address_type_set( address_type_set: &AddressTypeSet, builder: &mut veilid_capnp::address_type_set::Builder, ) -> Result<(), RPCError> { @@ -10,7 +10,7 @@ pub fn encode_address_type_set( Ok(()) } -pub fn decode_address_type_set( +pub(crate) fn decode_address_type_set( reader: &veilid_capnp::address_type_set::Reader, ) -> Result { let mut out = AddressTypeSet::new(); diff --git a/veilid-core/src/rpc_processor/coders/dial_info.rs b/veilid-core/src/rpc_processor/coders/dial_info.rs index 94d3c9ae..fc6c45f8 100644 --- a/veilid-core/src/rpc_processor/coders/dial_info.rs +++ b/veilid-core/src/rpc_processor/coders/dial_info.rs @@ -1,7 +1,9 @@ use super::*; use core::convert::TryInto; -pub fn decode_dial_info(reader: &veilid_capnp::dial_info::Reader) -> Result { +pub(crate) fn decode_dial_info( + reader: &veilid_capnp::dial_info::Reader, +) -> Result { match reader .reborrow() .which() @@ -60,7 +62,7 @@ pub fn decode_dial_info(reader: &veilid_capnp::dial_info::Reader) -> Result Result<(), RPCError> { diff --git a/veilid-core/src/rpc_processor/coders/dial_info_class.rs b/veilid-core/src/rpc_processor/coders/dial_info_class.rs index 835f060e..c6eeeb08 100644 --- a/veilid-core/src/rpc_processor/coders/dial_info_class.rs +++ b/veilid-core/src/rpc_processor/coders/dial_info_class.rs @@ -1,6 +1,8 @@ use super::*; -pub fn encode_dial_info_class(dial_info_class: DialInfoClass) -> veilid_capnp::DialInfoClass { +pub(crate) fn encode_dial_info_class( + dial_info_class: DialInfoClass, +) -> veilid_capnp::DialInfoClass { match dial_info_class { DialInfoClass::Direct => veilid_capnp::DialInfoClass::Direct, DialInfoClass::Mapped => veilid_capnp::DialInfoClass::Mapped, @@ -11,7 +13,9 @@ pub fn encode_dial_info_class(dial_info_class: DialInfoClass) -> veilid_capnp::D } } -pub fn decode_dial_info_class(dial_info_class: veilid_capnp::DialInfoClass) -> DialInfoClass { +pub(crate) fn decode_dial_info_class( + dial_info_class: veilid_capnp::DialInfoClass, +) -> DialInfoClass { match dial_info_class { veilid_capnp::DialInfoClass::Direct => DialInfoClass::Direct, veilid_capnp::DialInfoClass::Mapped => DialInfoClass::Mapped, diff --git a/veilid-core/src/rpc_processor/coders/dial_info_detail.rs b/veilid-core/src/rpc_processor/coders/dial_info_detail.rs index 7b012fe3..05f90ba0 100644 --- a/veilid-core/src/rpc_processor/coders/dial_info_detail.rs +++ b/veilid-core/src/rpc_processor/coders/dial_info_detail.rs @@ -1,6 +1,6 @@ use super::*; -pub fn encode_dial_info_detail( +pub(crate) fn encode_dial_info_detail( dial_info_detail: &DialInfoDetail, builder: &mut veilid_capnp::dial_info_detail::Builder, ) -> Result<(), RPCError> { @@ -11,7 +11,7 @@ pub fn encode_dial_info_detail( Ok(()) } -pub fn decode_dial_info_detail( +pub(crate) fn decode_dial_info_detail( reader: &veilid_capnp::dial_info_detail::Reader, ) -> Result { let dial_info = decode_dial_info( diff --git a/veilid-core/src/rpc_processor/coders/key256.rs b/veilid-core/src/rpc_processor/coders/key256.rs index 41a02cc5..ed6819dd 100644 --- a/veilid-core/src/rpc_processor/coders/key256.rs +++ b/veilid-core/src/rpc_processor/coders/key256.rs @@ -1,7 +1,7 @@ use super::*; use core::convert::TryInto; -pub fn decode_key256(public_key: &veilid_capnp::key256::Reader) -> PublicKey { +pub(crate) fn decode_key256(public_key: &veilid_capnp::key256::Reader) -> PublicKey { let u0 = public_key.get_u0().to_be_bytes(); let u1 = public_key.get_u1().to_be_bytes(); let u2 = public_key.get_u2().to_be_bytes(); @@ -16,7 +16,7 @@ pub fn decode_key256(public_key: &veilid_capnp::key256::Reader) -> PublicKey { PublicKey::new(x) } -pub fn encode_key256(key: &PublicKey, builder: &mut veilid_capnp::key256::Builder) { +pub(crate) fn encode_key256(key: &PublicKey, builder: &mut veilid_capnp::key256::Builder) { builder.set_u0(u64::from_be_bytes( key.bytes[0..8] .try_into() diff --git a/veilid-core/src/rpc_processor/coders/mod.rs b/veilid-core/src/rpc_processor/coders/mod.rs index 4f76486a..5b9c43b6 100644 --- a/veilid-core/src/rpc_processor/coders/mod.rs +++ b/veilid-core/src/rpc_processor/coders/mod.rs @@ -27,21 +27,22 @@ mod tunnel; mod typed_key; mod typed_signature; -pub use address::*; -pub use address_type_set::*; -pub use dial_info::*; -pub use dial_info_class::*; -pub use dial_info_detail::*; -pub use key256::*; -pub use network_class::*; -pub use node_info::*; -pub use node_status::*; -pub use nonce::*; -pub use operations::*; -pub use peer_info::*; -pub use private_safety_route::*; -pub use protocol_type_set::*; -pub use sender_info::*; +pub(in crate::rpc_processor) use operations::*; + +pub(crate) use address::*; +pub(crate) use address_type_set::*; +pub(crate) use dial_info::*; +pub(crate) use dial_info_class::*; +pub(crate) use dial_info_detail::*; +pub(crate) use key256::*; +pub(crate) use network_class::*; +pub(crate) use node_info::*; +pub(crate) use node_status::*; +pub(crate) use nonce::*; +pub(crate) use peer_info::*; +pub(crate) use private_safety_route::*; +pub(crate) use protocol_type_set::*; +pub(crate) use sender_info::*; pub use sequencing::*; pub use signal_info::*; pub use signature512::*; @@ -59,14 +60,14 @@ pub use typed_signature::*; use super::*; #[derive(Debug, Clone)] -pub enum QuestionContext { +pub(in crate::rpc_processor) enum QuestionContext { GetValue(ValidateGetValueContext), SetValue(ValidateSetValueContext), } #[derive(Clone)] -pub struct RPCValidateContext { +pub(in crate::rpc_processor) struct RPCValidateContext { pub crypto: Crypto, - pub rpc_processor: RPCProcessor, + // pub rpc_processor: RPCProcessor, pub question_context: Option, } diff --git a/veilid-core/src/rpc_processor/coders/operations/mod.rs b/veilid-core/src/rpc_processor/coders/operations/mod.rs index 72f4c520..c73628d1 100644 --- a/veilid-core/src/rpc_processor/coders/operations/mod.rs +++ b/veilid-core/src/rpc_processor/coders/operations/mod.rs @@ -29,34 +29,34 @@ mod operation_complete_tunnel; #[cfg(feature = "unstable-tunnels")] mod operation_start_tunnel; -pub use answer::*; -pub use operation::*; -pub use operation_app_call::*; -pub use operation_app_message::*; -pub use operation_find_node::*; -pub use operation_get_value::*; -pub use operation_return_receipt::*; -pub use operation_route::*; -pub use operation_set_value::*; -pub use operation_signal::*; -pub use operation_status::*; -pub use operation_validate_dial_info::*; -pub use operation_value_changed::*; -pub use operation_watch_value::*; -pub use question::*; -pub use respond_to::*; -pub use statement::*; +pub(in crate::rpc_processor) use answer::*; +pub(in crate::rpc_processor) use operation::*; +pub(in crate::rpc_processor) use operation_app_call::*; +pub(in crate::rpc_processor) use operation_app_message::*; +pub(in crate::rpc_processor) use operation_find_node::*; +pub(in crate::rpc_processor) use operation_get_value::*; +pub(in crate::rpc_processor) use operation_return_receipt::*; +pub(in crate::rpc_processor) use operation_route::*; +pub(in crate::rpc_processor) use operation_set_value::*; +pub(in crate::rpc_processor) use operation_signal::*; +pub(in crate::rpc_processor) use operation_status::*; +pub(in crate::rpc_processor) use operation_validate_dial_info::*; +pub(in crate::rpc_processor) use operation_value_changed::*; +pub(in crate::rpc_processor) use operation_watch_value::*; +pub(in crate::rpc_processor) use question::*; +pub(in crate::rpc_processor) use respond_to::*; +pub(in crate::rpc_processor) use statement::*; #[cfg(feature = "unstable-blockstore")] -pub use operation_find_block::*; +pub(in crate::rpc_processor) use operation_find_block::*; #[cfg(feature = "unstable-blockstore")] -pub use operation_supply_block::*; +pub(in crate::rpc_processor) use operation_supply_block::*; #[cfg(feature = "unstable-tunnels")] -pub use operation_cancel_tunnel::*; +pub(in crate::rpc_processor) use operation_cancel_tunnel::*; #[cfg(feature = "unstable-tunnels")] -pub use operation_complete_tunnel::*; +pub(in crate::rpc_processor) use operation_complete_tunnel::*; #[cfg(feature = "unstable-tunnels")] -pub use operation_start_tunnel::*; +pub(in crate::rpc_processor) use operation_start_tunnel::*; use super::*; diff --git a/veilid-core/src/rpc_processor/coders/operations/operation_route.rs b/veilid-core/src/rpc_processor/coders/operations/operation_route.rs index 4cd8bb89..510148af 100644 --- a/veilid-core/src/rpc_processor/coders/operations/operation_route.rs +++ b/veilid-core/src/rpc_processor/coders/operations/operation_route.rs @@ -1,7 +1,7 @@ use super::*; #[derive(Clone)] -pub(crate) struct RoutedOperation { +pub(in crate::rpc_processor) struct RoutedOperation { sequencing: Sequencing, signatures: Vec, nonce: Nonce, @@ -106,7 +106,7 @@ impl RoutedOperation { } #[derive(Debug, Clone)] -pub(crate) struct RPCOperationRoute { +pub(in crate::rpc_processor) struct RPCOperationRoute { safety_route: SafetyRoute, operation: RoutedOperation, } diff --git a/veilid-core/src/rpc_processor/coders/operations/operation_status.rs b/veilid-core/src/rpc_processor/coders/operations/operation_status.rs index 4a5e991d..f2725c18 100644 --- a/veilid-core/src/rpc_processor/coders/operations/operation_status.rs +++ b/veilid-core/src/rpc_processor/coders/operations/operation_status.rs @@ -1,7 +1,7 @@ use super::*; #[derive(Debug, Clone)] -pub struct RPCOperationStatusQ { +pub(in crate::rpc_processor) struct RPCOperationStatusQ { node_status: Option, } @@ -43,7 +43,7 @@ impl RPCOperationStatusQ { } #[derive(Debug, Clone)] -pub struct RPCOperationStatusA { +pub(in crate::rpc_processor) struct RPCOperationStatusA { node_status: Option, sender_info: Option, } diff --git a/veilid-core/src/rpc_processor/coders/operations/operation_validate_dial_info.rs b/veilid-core/src/rpc_processor/coders/operations/operation_validate_dial_info.rs index fa76e1bd..8a5848fe 100644 --- a/veilid-core/src/rpc_processor/coders/operations/operation_validate_dial_info.rs +++ b/veilid-core/src/rpc_processor/coders/operations/operation_validate_dial_info.rs @@ -1,7 +1,7 @@ use super::*; #[derive(Debug, Clone)] -pub struct RPCOperationValidateDialInfo { +pub(in crate::rpc_processor) struct RPCOperationValidateDialInfo { dial_info: DialInfo, receipt: Vec, redirect: bool, diff --git a/veilid-core/src/rpc_processor/coders/operations/operation_value_changed.rs b/veilid-core/src/rpc_processor/coders/operations/operation_value_changed.rs index 9ccc2295..36880e96 100644 --- a/veilid-core/src/rpc_processor/coders/operations/operation_value_changed.rs +++ b/veilid-core/src/rpc_processor/coders/operations/operation_value_changed.rs @@ -2,7 +2,7 @@ use super::*; use crate::storage_manager::SignedValueData; #[derive(Debug, Clone)] -pub struct RPCOperationValueChanged { +pub(in crate::rpc_processor) struct RPCOperationValueChanged { key: TypedKey, subkeys: ValueSubkeyRangeSet, count: u32, diff --git a/veilid-core/src/rpc_processor/destination.rs b/veilid-core/src/rpc_processor/destination.rs index cdee2666..8d58e6d8 100644 --- a/veilid-core/src/rpc_processor/destination.rs +++ b/veilid-core/src/rpc_processor/destination.rs @@ -2,7 +2,7 @@ use super::*; /// Where to send an RPC message #[derive(Debug, Clone)] -pub enum Destination { +pub(crate) enum Destination { /// Send to node directly Direct { /// The node to send to diff --git a/veilid-core/src/rpc_processor/fanout_call.rs b/veilid-core/src/rpc_processor/fanout_call.rs index 1ff4e8d0..efa7f7f2 100644 --- a/veilid-core/src/rpc_processor/fanout_call.rs +++ b/veilid-core/src/rpc_processor/fanout_call.rs @@ -8,14 +8,14 @@ where result: Option>, } -pub type FanoutCallReturnType = RPCNetworkResult>; -pub type FanoutNodeInfoFilter = Arc bool + Send + Sync>; +pub(crate) type FanoutCallReturnType = RPCNetworkResult>; +pub(crate) type FanoutNodeInfoFilter = Arc bool + Send + Sync>; -pub fn empty_fanout_node_info_filter() -> FanoutNodeInfoFilter { +pub(crate) fn empty_fanout_node_info_filter() -> FanoutNodeInfoFilter { Arc::new(|_, _| true) } -pub fn capability_fanout_node_info_filter(caps: Vec) -> FanoutNodeInfoFilter { +pub(crate) fn capability_fanout_node_info_filter(caps: Vec) -> FanoutNodeInfoFilter { Arc::new(move |_, ni| ni.has_capabilities(&caps)) } @@ -34,7 +34,7 @@ pub fn capability_fanout_node_info_filter(caps: Vec) -> FanoutNodeIn /// If the algorithm times out, a Timeout result is returned, however operations will still have been performed and a /// timeout is not necessarily indicative of an algorithmic 'failure', just that no definitive stopping condition was found /// in the given time -pub struct FanoutCall +pub(crate) struct FanoutCall where R: Unpin, F: Future, diff --git a/veilid-core/src/rpc_processor/fanout_queue.rs b/veilid-core/src/rpc_processor/fanout_queue.rs index 3655012b..2f624da7 100644 --- a/veilid-core/src/rpc_processor/fanout_queue.rs +++ b/veilid-core/src/rpc_processor/fanout_queue.rs @@ -1,6 +1,6 @@ use super::*; -pub struct FanoutQueue { +pub(in crate::rpc_processor) struct FanoutQueue { crypto_kind: CryptoKind, current_nodes: VecDeque, returned_nodes: HashSet, diff --git a/veilid-core/src/rpc_processor/mod.rs b/veilid-core/src/rpc_processor/mod.rs index 7b07817e..dbcd637a 100644 --- a/veilid-core/src/rpc_processor/mod.rs +++ b/veilid-core/src/rpc_processor/mod.rs @@ -29,13 +29,12 @@ mod rpc_complete_tunnel; #[cfg(feature = "unstable-tunnels")] mod rpc_start_tunnel; -pub use coders::*; -pub use destination::*; -pub use fanout_call::*; -pub use fanout_queue::*; -pub use operation_waiter::*; -pub use rpc_error::*; -pub use rpc_status::*; +pub(crate) use coders::*; +pub(crate) use destination::*; +pub(crate) use operation_waiter::*; +pub(crate) use rpc_error::*; +pub(crate) use rpc_status::*; +pub(crate) use fanout_call::*; use super::*; @@ -43,6 +42,7 @@ use crypto::*; use futures_util::StreamExt; use network_manager::*; use routing_table::*; +use fanout_queue::*; use stop_token::future::FutureExt; use storage_manager::*; @@ -268,13 +268,13 @@ enum RPCKind { ///////////////////////////////////////////////////////////////////// -pub struct RPCProcessorInner { +struct RPCProcessorInner { send_channel: Option, RPCMessageEncoded)>>, stop_source: Option, worker_join_handles: Vec>, } -pub struct RPCProcessorUnlockedInner { +struct RPCProcessorUnlockedInner { timeout_us: TimestampDuration, queue_size: u32, concurrency: u32, @@ -286,7 +286,7 @@ pub struct RPCProcessorUnlockedInner { } #[derive(Clone)] -pub struct RPCProcessor { +pub(crate) struct RPCProcessor { crypto: Crypto, config: VeilidConfig, network_manager: NetworkManager, @@ -974,11 +974,16 @@ impl RPCProcessor { safety_route: Option, remote_private_route: Option, ) { - let wants_answer = matches!(rpc_kind, RPCKind::Question); - // Record for node if this was not sent via a route if safety_route.is_none() && remote_private_route.is_none() { - node_ref.stats_question_sent(send_ts, bytes, wants_answer); + let wants_answer = matches!(rpc_kind, RPCKind::Question); + let is_answer = matches!(rpc_kind, RPCKind::Answer); + + if is_answer { + node_ref.stats_answer_sent(bytes); + } else { + node_ref.stats_question_sent(send_ts, bytes, wants_answer); + } return; } @@ -1422,7 +1427,7 @@ impl RPCProcessor { // Validate the RPC operation let validate_context = RPCValidateContext { crypto: self.crypto.clone(), - rpc_processor: self.clone(), + // rpc_processor: self.clone(), question_context, }; operation.validate(&validate_context)?; diff --git a/veilid-core/src/rpc_processor/rpc_route.rs b/veilid-core/src/rpc_processor/rpc_route.rs index d33b9055..0325f82c 100644 --- a/veilid-core/src/rpc_processor/rpc_route.rs +++ b/veilid-core/src/rpc_processor/rpc_route.rs @@ -272,7 +272,8 @@ impl RPCProcessor { feature = "verbose-tracing", instrument(level = "trace", skip_all, err) )] - pub(crate) async fn process_private_route_first_hop( + + async fn process_private_route_first_hop( &self, mut routed_operation: RoutedOperation, sr_pubkey: TypedKey, @@ -336,7 +337,7 @@ impl RPCProcessor { } /// Decrypt route hop data and sign routed operation - pub(crate) fn decrypt_private_route_hop_data( + fn decrypt_private_route_hop_data( &self, route_hop_data: &RouteHopData, pr_pubkey: &TypedKey, diff --git a/veilid-core/src/rpc_processor/rpc_status.rs b/veilid-core/src/rpc_processor/rpc_status.rs index 292d4b0d..9b831571 100644 --- a/veilid-core/src/rpc_processor/rpc_status.rs +++ b/veilid-core/src/rpc_processor/rpc_status.rs @@ -115,12 +115,7 @@ impl RPCProcessor { if protect { self.network_manager() .connection_manager() - .protect_connection( - waitable_reply - .send_data_method - .connection_descriptor - .clone(), - ); + .protect_connection(waitable_reply.send_data_method.connection_descriptor); } // Note what kind of ping this was and to what peer scope diff --git a/veilid-core/src/storage_manager/mod.rs b/veilid-core/src/storage_manager/mod.rs index a04ec1ba..f262d870 100644 --- a/veilid-core/src/storage_manager/mod.rs +++ b/veilid-core/src/storage_manager/mod.rs @@ -44,7 +44,7 @@ struct StorageManagerUnlockedInner { } #[derive(Clone)] -pub struct StorageManager { +pub(crate) struct StorageManager { unlocked_inner: Arc, inner: Arc>, }