Skip to main content

ipfrs_network/
lib.rs

1//! IPFRS Network - libp2p-based networking layer
2//!
3//! This crate provides the networking infrastructure for IPFRS including:
4//! - libp2p node management with full protocol support
5//! - QUIC transport with TCP fallback for reliable connectivity
6//! - Kademlia DHT for content and peer discovery
7//! - Bitswap protocol for block exchange
8//! - mDNS for local peer discovery
9//! - Bootstrap peer management with retry logic and circuit breaker
10//! - Provider record caching with TTL and LRU eviction
11//! - Connection limits and intelligent pruning
12//! - Network metrics and Prometheus export
13//! - NAT traversal (AutoNAT, DCUtR, Circuit Relay v2)
14//! - Query optimization with early termination and pipelining
15//! - Comprehensive health monitoring and logging
16//!
17//! ## Features
18//!
19//! ### Core Networking
20//! - **Multi-transport**: QUIC (primary) with TCP fallback for maximum compatibility
21//! - **NAT Traversal**: AutoNAT for detection, DCUtR for hole punching, Circuit Relay for fallback
22//! - **Peer Discovery**: Kademlia DHT, mDNS for local peers, configurable bootstrap nodes
23//! - **Connection Management**: Intelligent limits, priority-based pruning, bandwidth tracking
24//!
25//! ### DHT Operations
26//! - **Content Routing**: Provider record publishing and discovery with automatic refresh
27//! - **Peer Routing**: Find closest peers, routing table management
28//! - **Query Optimization**: Early termination, pipelining, quality scoring
29//! - **Caching**: Query results and provider records with TTL-based expiration
30//! - **Semantic Routing**: Vector-based content discovery using embeddings and LSH
31//!
32//! ### Pub/Sub Messaging
33//! - **GossipSub**: Topic-based publish/subscribe messaging
34//! - **Mesh Formation**: Automatic peer mesh optimization for topic propagation
35//! - **Message Deduplication**: Efficient duplicate detection
36//! - **Peer Scoring**: Quality-based peer selection for reliable delivery
37//!
38//! ### Reliability
39//! - **Retry Logic**: Exponential backoff with configurable limits
40//! - **Circuit Breaker**: Prevent cascading failures with failing peers
41//! - **Fallback Strategies**: Alternative peers, relay fallback, degraded mode
42//! - **Health Monitoring**: DHT health, connection health, bandwidth metrics
43//!
44//! ### Monitoring & Observability
45//! - **Metrics**: Connection stats, DHT stats, bandwidth tracking, query performance
46//! - **Prometheus Export**: Ready-to-use metrics export for monitoring systems
47//! - **Structured Logging**: Tracing spans with context propagation
48//! - **Health Checks**: Component-level and overall health assessment
49//!
50//! ## Quick Start
51//!
52//! ```rust,no_run
53//! use ipfrs_network::{NetworkConfig, NetworkNode};
54//!
55//! #[tokio::main]
56//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
57//!     // Create configuration
58//!     let config = NetworkConfig {
59//!         listen_addrs: vec!["/ip4/0.0.0.0/udp/0/quic-v1".to_string()],
60//!         enable_quic: true,
61//!         enable_mdns: true,
62//!         enable_nat_traversal: true,
63//!         ..Default::default()
64//!     };
65//!
66//!     // Create and start network node
67//!     let mut node = NetworkNode::new(config)?;
68//!     node.start().await?;
69//!
70//!     // Check network health
71//!     let health = node.get_network_health();
72//!     println!("Network status: {:?}", health.status);
73//!
74//!     // Announce content to DHT
75//!     let cid = cid::Cid::default();
76//!     node.provide(&cid).await?;
77//!
78//!     // Get network statistics
79//!     let stats = node.stats();
80//!     println!("Connected peers: {}", stats.connected_peers);
81//!
82//!     Ok(())
83//! }
84//! ```
85//!
86//! ## High-Level Facade
87//!
88//! For easy integration of all features, use the `NetworkFacade`:
89//!
90//! ```rust,no_run
91//! use ipfrs_network::NetworkFacadeBuilder;
92//!
93//! #[tokio::main]
94//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
95//!     // Create a mobile-optimized node with advanced features
96//!     let mut facade = NetworkFacadeBuilder::new()
97//!         .with_preset_mobile()
98//!         .with_semantic_dht()
99//!         .with_gossipsub()
100//!         .build()?;
101//!
102//!     facade.start().await?;
103//!     println!("Peer ID: {}", facade.peer_id());
104//!     Ok(())
105//! }
106//! ```
107//!
108//! ## Architecture
109//!
110//! The crate is organized into several modules:
111//!
112//! - **facade**: High-level facade for easy integration of all modules
113//! - **auto_tuner**: Automatic network configuration tuning based on system resources
114//! - **benchmarking**: Performance benchmarking utilities for network components
115//! - **node**: Core `NetworkNode` implementation with libp2p swarm management
116//! - **dht**: Kademlia DHT operations and caching
117//! - **peer**: Peer store for tracking known peers and their metadata
118//! - **connection_manager**: Connection limits and intelligent pruning
119//! - **bootstrap**: Bootstrap peer management with retry logic
120//! - **providers**: Provider record caching with TTL
121//! - **query_optimizer**: Query optimization and performance tracking
122//! - **metrics**: Network metrics and Prometheus export
123//! - **health**: Health monitoring for network components
124//! - **logging**: Structured logging and tracing
125//! - **protocol**: Custom protocol support and version negotiation
126//! - **fallback**: Fallback strategies for resilience
127//! - **semantic_dht**: Vector-based semantic DHT for content routing by similarity
128//! - **gossipsub**: Topic-based pub/sub messaging with mesh optimization
129//! - **geo_routing**: Geographic routing optimization for proximity-based peer selection
130//! - **dht_provider**: Pluggable DHT provider interface for custom DHT implementations
131//! - **peer_selector**: Intelligent peer selection combining geographic proximity and quality metrics
132//! - **multipath_quic**: QUIC multipath support for using multiple network paths simultaneously
133//! - **tor**: Tor integration for privacy-preserving networking with onion routing and hidden services
134//! - **diagnostics**: Network diagnostics and troubleshooting utilities
135//! - **session**: Connection session management with lifecycle tracking and statistics
136//! - **rate_limiter**: Connection rate limiting for preventing connection storms and resource exhaustion
137//! - **reputation**: Peer reputation system for tracking and scoring peer behavior over time
138//! - **metrics_aggregator**: Time-series metrics aggregation with statistical analysis and trend tracking
139//! - **load_tester**: Load testing and stress testing utilities for performance validation
140//! - **traffic_analyzer**: Traffic pattern analysis and anomaly detection for network insights
141//! - **network_simulator**: Network condition simulation for testing under adverse conditions
142//! - **policy**: Network policy engine for fine-grained control over operations
143//! - **utils**: Common utility functions for formatting, parsing, and network operations
144//!
145//! ## Examples
146//!
147//! See the `examples/` directory for more comprehensive examples:
148//! - `network_facade_demo.rs`: Using the NetworkFacade for easy integration
149//! - `basic_node.rs`: Creating and starting a basic network node
150//! - `dht_operations.rs`: Content announcement and provider discovery
151//! - `connection_management.rs`: Connection tracking and bandwidth monitoring
152
153pub mod adaptive_bandwidth_allocator;
154pub use adaptive_bandwidth_allocator::{
155    AdaptiveBandwidthAllocator,
156    AllocationPolicy,
157    AllocatorConfig,
158    AllocatorError,
159    BandwidthClass,
160    BandwidthEvent,
161    // BandwidthStats collides with bandwidth_monitor::BandwidthStats → Aba prefix.
162    BandwidthStats as AbaBandwidthStats,
163    BandwidthWindow,
164    PeerBandwidthProfile,
165};
166
167pub mod adaptive_peer_scheduler;
168pub use adaptive_peer_scheduler::{
169    AdaptivePeerScheduler,
170    // BackpressureSignal conflicts with rate_limiter::BackpressureSignal → alias.
171    BackpressureSignal as ApsBackpressureSignal,
172    // PeerMetrics conflicts with peer_scoring::PeerMetrics → alias.
173    PeerMetrics as ApsPeerMetrics,
174    ScheduleSlot,
175    SchedulerConfig as ApsSchedulerConfig,
176    SchedulerStats as ApsSchedulerStats,
177};
178
179pub mod anti_entropy;
180pub use anti_entropy::{
181    AntiEntropyConfig, DigestEntry, GossipAntiEntropy, MerkleDigest, ReconcileResult,
182};
183
184pub mod block_transfer;
185pub use block_transfer::{
186    BlockTransfer, StreamingBlockTransfer, TransferChunk, TransferDirection, TransferManagerStats,
187    TransferState,
188};
189
190pub mod bandwidth_allocator;
191pub use bandwidth_allocator::{
192    AllocationStats, AllocationStrategy, PeerAllocation, PeerBandwidthAllocator,
193};
194
195pub mod bandwidth_budget;
196pub use bandwidth_budget::{
197    BandwidthBudgetManager, BandwidthQuota, BudgetConfig, BudgetStats, PeerBucket,
198};
199
200pub mod bandwidth_monitor;
201pub use bandwidth_monitor::{
202    BandwidthAnomaly,
203    BandwidthMonitor,
204    BandwidthMonitorStats,
205    BandwidthSample,
206    BandwidthStats,
207    BandwidthStatsSnapshot,
208    Direction,
209    MonitorConfig,
210    PeerBandwidth,
211    // Tick-based peer bandwidth monitor
212    PeerBandwidthMonitor,
213    PeerBandwidthWindow,
214    TickBandwidthSample,
215};
216
217pub mod adaptive_timeout;
218pub use adaptive_timeout::{
219    AdaptiveTimeoutConfig, PeerAdaptiveTimeout, RttSample, TimeoutEstimate, TimeoutStats,
220};
221
222pub mod adaptive_lookup;
223pub mod adaptive_polling;
224pub mod arm_profiler;
225pub mod auto_tuner;
226pub mod background_mode;
227pub mod batch_resolver;
228pub mod benchmarking;
229pub mod bitswap;
230pub mod bootstrap;
231pub mod bootstrap_coordinator;
232pub mod capability_registry;
233pub mod cert_pin;
234pub mod churn_resilience;
235pub mod connection_drainer;
236pub mod content_routing_optimizer;
237pub mod identity;
238pub mod mesh_repair;
239pub mod relay;
240pub use connection_drainer::{
241    ConnectionDrainer, DrainState, DrainableConnection, DrainerConfig, DrainerStats,
242};
243pub mod connection_health_monitor;
244pub use connection_health_monitor::{
245    AlertThresholds, ChmAlertSeverity, ChmHealthAlert, ChmHealthMetric, ChmHealthSample,
246    ChmMonitorStats, ConnectionHealth, ConnectionHealthMonitor,
247};
248
249pub mod connection_manager;
250pub mod connection_migration;
251pub mod dht;
252pub mod dht_optimizer;
253pub mod dht_provider;
254pub mod diagnostics;
255pub mod event_bus;
256pub mod facade;
257pub mod fallback;
258pub mod geo_routing;
259pub mod gossipsub;
260pub mod health;
261pub mod ipfs_compat;
262pub mod load_tester;
263pub mod logging;
264pub mod memory_monitor;
265pub mod metrics;
266pub mod metrics_aggregator;
267pub mod multipath_quic;
268pub mod nat_traversal;
269pub mod nat_traversal_manager;
270pub use nat_traversal_manager::{
271    fnv1a_64 as ntm_fnv1a_64,
272    xorshift64 as ntm_xorshift64,
273    CandidateAddress,
274    CandidateType,
275    IcePair,
276    // NatTraversalManager collides with nat_traversal::NatTraversalManager → Ntm prefix.
277    NatTraversalManager as NtmNatTraversalManager,
278    // NatType collides with nat_traversal::NatType → Ntm prefix.
279    NatType as NtmNatType,
280    PairState,
281    StunAttribute,
282    StunMessage,
283    StunMessageType,
284    TraversalConfig as NtmTraversalConfig,
285    TraversalError,
286    TraversalStats as NtmTraversalStats,
287};
288pub mod network_monitor;
289pub mod network_simulator;
290pub mod node;
291pub mod offline_queue;
292pub mod peer;
293pub mod peer_blacklist;
294pub use peer_blacklist::{
295    BlacklistConfig, BlacklistEntry, BlacklistReason, BlacklistStats, PeerBlacklist,
296};
297
298pub mod peer_capabilities;
299pub mod peer_discovery;
300pub mod peer_exchange;
301pub mod peer_migration;
302pub use peer_exchange::{PeerExchangeProtocol, PeerSource, PexConfig, PexPeerRecord, PexStats};
303pub use peer_migration::{
304    MigrationItem as PmMigrationItem, PeerMigrationConfig as PmMigrationConfig,
305    PeerMigrationManager, PeerMigrationRecord, PeerMigrationState as PmMigrationState,
306    PeerMigrationStats as PmMigrationStats,
307};
308pub mod lookup_cache;
309pub mod peer_health;
310pub mod peer_score;
311pub mod peer_selector;
312pub mod policy;
313pub mod presets;
314pub mod protocol;
315pub mod provider_renewal;
316pub mod providers;
317pub mod quality_predictor;
318pub mod query_batcher;
319pub mod query_optimizer;
320pub mod quic;
321pub mod rate_limiter;
322pub mod reputation;
323pub mod semantic_dht;
324pub mod session;
325pub mod throttle;
326pub mod topic_router;
327pub mod tor;
328pub mod traffic_shaper;
329pub use traffic_shaper::{
330    tokens_available,
331    xorshift64 as ts_xorshift64,
332    xorshift_f64 as ts_xorshift_f64,
333    DropPolicy,
334    PeerShaperStats,
335    PeerTokenBucket,
336    // Legacy peer shaper types (renamed to avoid clashes)
337    PeerTrafficClass,
338    PeerTrafficShaper,
339    QueueEntry,
340    QueuingDiscipline,
341    ShaperConfig,
342    ShaperError,
343    ShaperEvent,
344    ShaperStats,
345    // New discipline-based shaper types
346    TrafficClass,
347    TrafficShaper,
348    TrafficToken,
349};
350pub mod routing_table;
351pub mod traffic_analyzer;
352pub mod utils;
353
354pub use adaptive_lookup::{
355    AdaptiveLookupScheduler, LookupSchedulerStats, PeerLatencyTracker, ALPHA_DEFAULT, ALPHA_MAX,
356    ALPHA_MIN,
357};
358pub use adaptive_polling::{
359    ActivityLevel, AdaptivePolling, AdaptivePollingConfig, AdaptivePollingError,
360    AdaptivePollingStats,
361};
362pub use arm_profiler::{
363    ArmDevice, ArmProfiler, PerformanceSample, PerformanceStats, ProfilerConfig, ProfilerError,
364};
365pub use auto_tuner::{
366    AutoTuner, AutoTunerConfig, AutoTunerError, AutoTunerStats, SystemResources, WorkloadProfile,
367};
368pub use background_mode::{
369    BackgroundModeConfig, BackgroundModeError, BackgroundModeManager, BackgroundModeStats,
370    BackgroundState,
371};
372pub use batch_resolver::{
373    BatchCidResolver, BatchResolverStats, BatchResolverStatsSnapshot, CachedResult, LookupHandle,
374    PendingLookup, PrefetchScheduler,
375};
376pub use benchmarking::{
377    BenchmarkConfig, BenchmarkError, BenchmarkResult, BenchmarkType, PerformanceBenchmark,
378};
379pub use bitswap::{Bitswap, BitswapEvent, BitswapMessage, BitswapStats};
380pub use bootstrap::{BootstrapConfig, BootstrapManager, BootstrapStats};
381pub use bootstrap_coordinator::{
382    BootstrapCoordinator, BootstrapPeer, BootstrapStats as CoordinatorBootstrapStats,
383    BootstrapStatsSnapshot, DiscoveryRecord,
384};
385pub use capability_registry::{
386    // Protocol-level capability types (PeerCapabilityRegistry)
387    Capability,
388    CapabilityAdvertisement,
389    CapabilityRegistryStats,
390    NodeCapabilities,
391    // Node-level capability types (NodeCapabilityRegistry)
392    NodeCapability,
393    NodeCapabilityRegistry,
394    PeerCapabilityRegistry,
395};
396pub use cert_pin::{CertFingerprint, CertPinStore, PeerCertPin, PinPolicy, VerificationResult};
397pub use churn_resilience::{
398    AdaptiveRefreshConfig, AdaptiveRefreshScheduler, ChurnEventType, ChurnMetrics,
399    ChurnResilienceManager, PeerChurnEvent, PeerChurnTracker,
400};
401pub use connection_manager::{
402    ConnectionDirection, ConnectionLimitsConfig, ConnectionManager, ConnectionManagerStats,
403};
404pub use connection_migration::{
405    ConnectionMigrationManager, MigrationAttempt, MigrationConfig, MigrationError, MigrationState,
406    MigrationStats,
407};
408pub use dht::{
409    DhtConfig, DhtHealth, DhtHealthStatus, DhtManager, DhtStats, ProviderReannouncer,
410    ReannounceStats,
411};
412pub use dht_provider::{
413    DhtCapabilities, DhtPeerInfo, DhtProvider, DhtProviderError, DhtProviderRegistry,
414    DhtProviderStats, DhtQueryResult,
415};
416pub use diagnostics::{
417    ConfigDiagnostics, ConfigIssue, DiagnosticResult, DiagnosticTest, NetworkDiagnostics,
418    PerformanceMetrics, TroubleshootingGuide,
419};
420pub use facade::{NetworkFacade, NetworkFacadeBuilder};
421pub use fallback::{FallbackConfig, FallbackManager, FallbackResult, FallbackStrategy, RetryStats};
422pub use geo_routing::{
423    GeoLocation, GeoPeer, GeoRegion, GeoRouter, GeoRouterConfig, GeoRouterStats,
424};
425pub use gossipsub::{
426    topics as gossipsub_topics, GossipSubConfig, GossipSubError, GossipSubManager,
427    GossipSubMessage, GossipSubStats, IpfrsTopic, MeshHealthMonitor, MeshHealthStatus, MessageId,
428    PeerScore, TopicId, TopicMessage, TopicSubscription,
429};
430pub use health::{
431    ComponentHealth, HealthChecker, HealthHistory, NetworkHealth, NetworkHealthStatus,
432};
433pub use identity::{IdentityError, PeerIdentityManager, PreviousKeypair, RotationRecord};
434pub use ipfs_compat::{
435    ipfs_test_config, test_ipfs_connectivity, IpfsCompatTestResults, IPFS_BOOTSTRAP_NODES,
436    TEST_CIDS,
437};
438pub use load_tester::{
439    LoadTestConfig, LoadTestError, LoadTestMetrics, LoadTestResults, LoadTestType, LoadTester,
440};
441pub use logging::{
442    connection_span, dht_span, network_span, LogLevel, LoggingConfig, NetworkEventType,
443    OperationContext,
444};
445pub use lookup_cache::{
446    CachedProviders, LookupCache, LookupCacheConfig, LookupCacheStats, ParallelLookupConfig,
447    ParallelLookupExecutor, ParallelLookupResult,
448};
449pub use memory_monitor::{
450    ComponentMemory, MemoryMonitor, MemoryMonitorConfig, MemoryMonitorError, MemoryStats,
451};
452pub use mesh_repair::{MeshRepairConfig, MeshRepairCoordinator, MeshRepairState};
453pub use metrics::{
454    BandwidthMetricsSnapshot, ConnectionMetricsSnapshot, DhtMetricsSnapshot, MetricsSnapshot,
455    NetworkMetrics, SharedMetrics,
456};
457pub use metrics_aggregator::{
458    AggregatedStatistics, AggregatorConfig, MetricStatistics, MetricsAggregator, TimeWindow,
459};
460pub use multipath_quic::{
461    MultipathConfig, MultipathError, MultipathQuicManager, MultipathStats, NetworkPath, PathId,
462    PathQuality, PathSelectionStrategy, PathState,
463};
464pub use nat_traversal::{
465    HolePunchAttempt, HolePunchStatus, NatTraversalConfig, NatTraversalManager, NatTraversalStats,
466    NatType, StunBinding, TraversalStrategy,
467};
468pub use network_monitor::{
469    InterfaceType, NetworkChange, NetworkInterface, NetworkMonitor, NetworkMonitorConfig,
470    NetworkMonitorError, NetworkMonitorStats,
471};
472pub use network_simulator::{
473    NetworkCondition, NetworkSimulator, SimulatorConfig, SimulatorError, SimulatorStats,
474};
475pub use node::{
476    BucketInfo, ConnectionEndpoint, InferenceWaiters, KademliaConfig, NatTraversalMetrics,
477    NetworkConfig, NetworkEvent, NetworkHealthLevel, NetworkHealthSummary, NetworkNode,
478    NetworkStats, RelayConfig, RoutingTableInfo,
479};
480pub use offline_queue::{
481    OfflineQueue, OfflineQueueConfig, OfflineQueueError, OfflineQueueStats, QueuedRequest,
482    QueuedRequestType, RequestPriority,
483};
484pub use peer::{PeerInfo, PeerStore, PeerStoreConfig, PeerStoreStats};
485pub use peer_capabilities::{
486    CapabilityConfig,
487    CapabilityRegistry,
488    CapabilityStats,
489    // Advertised as PeerCapability to avoid collision with capability_registry::Capability
490    PeerCapability,
491    PeerCapabilitySet,
492};
493pub use peer_selector::{
494    PeerSelector, PeerSelectorConfig, PeerSelectorStats, SelectedPeer, SelectionCriteria,
495};
496pub use policy::{
497    BandwidthPolicy, ConnectionPolicy, ContentPolicy, PolicyAction, PolicyConfig, PolicyEngine,
498    PolicyError, PolicyResult, PolicyStats,
499};
500pub use presets::NetworkPreset;
501pub use protocol::{
502    ProtocolCapabilities, ProtocolHandler, ProtocolId, ProtocolRegistry, ProtocolVersion,
503};
504pub use provider_renewal::{
505    ProviderRecord, ProviderRenewalScheduler, RenewalConfig, DEFAULT_PROVIDER_TTL_SECS,
506    DEFAULT_RENEWAL_THRESHOLD,
507};
508pub use providers::{ProviderCache, ProviderCacheConfig, ProviderCacheStats};
509pub use quality_predictor::{
510    QualityPrediction, QualityPredictor, QualityPredictorConfig, QualityPredictorError,
511    QualityPredictorStats,
512};
513pub use query_batcher::{
514    PendingQuery, QueryBatchResult, QueryBatcher, QueryBatcherConfig, QueryBatcherError,
515    QueryBatcherStats, QueryType,
516};
517pub use query_optimizer::{QueryMetrics, QueryOptimizer, QueryOptimizerConfig, QueryResult};
518pub use quic::{
519    CongestionControl, QuicConfig, QuicConnectionInfo, QuicConnectionState, QuicMonitor, QuicStats,
520};
521pub use rate_limiter::{
522    AtomicRateLimiterStats,
523    // New atomic types
524    AtomicTokenBucket,
525    BackpressureController,
526    BackpressureSignal,
527    ConnectionPriority,
528    ConnectionRateLimiter,
529    GlobalLimiter,
530    PeerLimiter,
531    PeerRateLimiter,
532    PeerRateLimiterConfig,
533    PeerRateLimiterStats,
534    RateLimitDecision,
535    // PeerRateLimiter
536    RateLimitResult,
537    RateLimiter,
538    RateLimiterConfig,
539    RateLimiterError,
540    RateLimiterStats,
541    RateLimiterStatsSnapshot,
542};
543pub use relay::{RelayError, RelayManager, RelayReservation};
544pub use reputation::{
545    PeerReputation, PeerReputationEvent, PeerReputationStats, PeerReputationStatsSnapshot,
546    PeerReputationTracker, PeerTier, ReputationConfig, ReputationEvent, ReputationManager,
547    ReputationScore, ReputationStats,
548};
549pub use semantic_dht::{
550    DistanceMetric, LshConfig, LshHash, MergeResult, NamespaceId, PartialSyncConfig,
551    PartialSyncStats, SearchResult, SemanticDht, SemanticDhtConfig, SemanticDhtError,
552    SemanticDhtMetrics, SemanticDhtStats, SemanticNamespace, SemanticQuery, SemanticResult,
553    ShardBalancer, ShardBalancerConfig, VectorAnnotatedRecord,
554};
555pub use session::{
556    Session, SessionConfig, SessionManager, SessionMetadata,
557    SessionState as ConnectionSessionState, SessionStats,
558};
559pub use throttle::{
560    BandwidthThrottle, ThrottleConfig, ThrottleError, ThrottleStats, TrafficDirection,
561};
562pub use topic_router::{
563    PrioritizedMessage, TopicConfig, TopicError, TopicRouter, TopicRouterStats,
564    TopicRouterStatsSnapshot,
565};
566pub use tor::{
567    CircuitId, CircuitInfo, CircuitState, HiddenServiceConfig, OnionAddress, StreamId, TorConfig,
568    TorError, TorManager, TorStats,
569};
570pub use traffic_analyzer::{
571    AnomalyType, PatternType, PeerProfile, TrafficAnalysis, TrafficAnalyzer, TrafficAnalyzerConfig,
572    TrafficAnalyzerError, TrafficAnalyzerStats, TrafficAnomaly, TrafficEvent, TrafficPattern,
573    TrendDirection,
574};
575
576pub use routing_table::{
577    ContentRoutingTable, RoutingEntry, RoutingError, RoutingTableStats, DEFAULT_ENTRY_TTL,
578    DEFAULT_MAX_PROVIDERS,
579};
580
581pub mod content_routing_cache;
582pub use content_routing_cache::{
583    CacheConfig as CrcCacheConfig,
584    CacheStats as CrcCacheStats,
585    ContentRoutingCache,
586    // ProviderRecord conflicts with provider_renewal::ProviderRecord → Crc prefix.
587    CrcProviderRecord,
588    NegativeCacheEntry,
589    RoutingHint,
590    DEFAULT_HINT_TTL_MS as CRC_DEFAULT_HINT_TTL_MS,
591    DEFAULT_MAX_HINTS as CRC_DEFAULT_MAX_HINTS,
592    DEFAULT_MAX_NEGATIVE as CRC_DEFAULT_MAX_NEGATIVE,
593    DEFAULT_MAX_PROVIDERS as CRC_DEFAULT_MAX_PROVIDERS,
594    DEFAULT_NEGATIVE_TTL_MS as CRC_DEFAULT_NEGATIVE_TTL_MS,
595    DEFAULT_PROVIDER_TTL_MS as CRC_DEFAULT_PROVIDER_TTL_MS,
596};
597
598pub mod routing_table_sharding;
599pub use routing_table_sharding::{
600    EvictionPolicy,
601    // NodeId conflicts with routing_table_manager::NodeId → alias.
602    NodeId as RtsNodeId,
603    // RoutingEntry conflicts with routing_table::RoutingEntry → alias.
604    RoutingEntry as RtsRoutingEntry,
605    RoutingTableSharding,
606    ShardConfig,
607    ShardId,
608    ShardStats,
609};
610
611pub mod routing_table_manager;
612pub use routing_table_manager::{
613    bucket_index as rtm_bucket_index, xor_distance as rtm_xor_distance, BucketEntry, KBucket,
614    NodeId, RoutingTableManager, RoutingTableStats as RtmRoutingTableStats,
615    DEFAULT_ALPHA as RTM_DEFAULT_ALPHA, DEFAULT_K as RTM_DEFAULT_K,
616    DEFAULT_REPLACEMENT_CACHE_SIZE as RTM_DEFAULT_REPLACEMENT_CACHE_SIZE,
617};
618
619pub mod peer_capability_negotiator;
620pub use peer_capability_negotiator::{
621    CapabilityPolicy,
622    CapabilityVersion,
623    NegotiationOffer,
624    NegotiationRecord,
625    // NegotiationResult conflicts with protocol_negotiator::NegotiationResult → Pcn prefix.
626    NegotiationResult as PcnNegotiationResult,
627    // NegotiatorConfig conflicts with protocol_negotiator::NegotiatorConfig → Pcn prefix.
628    NegotiatorConfig as PcnNegotiatorConfig,
629    NegotiatorStats,
630    // PeerCapability conflicts with peer_capabilities::PeerCapability → Pcn prefix.
631    PeerCapability as PcnPeerCapability,
632    PeerCapabilityNegotiator,
633};
634
635pub mod protocol_handshake;
636pub mod protocol_negotiator;
637pub use protocol_negotiator::{
638    NegotiationResult,
639    NegotiatorConfig,
640    PeerNegotiationResult,
641    PeerNegotiatorStats,
642    PeerProtocolNegotiator,
643    PeerProtocolVersion,
644    // Pn-prefixed rich negotiation system
645    PnNegotiatedSession,
646    PnNegotiationOutcome,
647    PnNegotiationRecord,
648    PnNegotiationStats,
649    PnNegotiatorConfig,
650    PnProtocolId,
651    PnProtocolNegotiator,
652    PnProtocolVersion,
653    PnSessionId,
654    ProtocolFeature,
655    ProtocolNegotiator,
656    ProtocolOffer,
657};
658pub mod protocol_version;
659pub use protocol_handshake::{
660    FeatureFlag, HandshakeError, HandshakeOffer, HandshakeResult, HandshakeStats,
661    HandshakeStatsSnapshot, ProtocolHandshaker, ProtocolVersion as HandshakeProtocolVersion,
662    DEFAULT_MAX_FRAME_SIZE,
663};
664pub use protocol_version::{
665    CompatibilityLevel, NegotiationResult as PvNegotiationResult, ProtocolDescriptor,
666    ProtocolVersion as PvProtocolVersion, ProtocolVersionManager, VersionStats,
667};
668
669pub mod gossip_metrics;
670pub use gossip_metrics::{GossipEvent, GossipMetricsSnapshot, MessageTrace, PeerGossipMetrics};
671
672pub mod gossip_overlay;
673pub use gossip_overlay::{
674    GossipFanout, GossipMessage, GossipOverlayManager, GossipState, GossipStats,
675    GossipStatsSnapshot,
676};
677
678pub mod connection_pool;
679pub use connection_pool::{
680    ConnectionPool,
681    ConnectionState,
682    // Tick-based peer pool
683    PeerConnectionPool,
684    PeerPoolConfig,
685    PeerPoolStats,
686    PeerPooledConnection,
687    PoolConfig,
688    PoolConnectionState,
689    PoolError,
690    PoolStats,
691    PoolStatsSnapshot,
692    PooledConnection,
693};
694
695pub mod connection_tracker;
696
697pub mod message_router;
698pub use message_router::{
699    HandlerRegistration,
700    MessagePriority,
701    MessageRouter,
702    // PeerMessageRouter and related types
703    MessageRouterStats,
704    MessageType,
705    PeerMessageRouter,
706    PeerRoutedMessage,
707    RouteRule,
708    RoutedMessage,
709    RouterError,
710    RouterStats,
711    RouterStatsSnapshot,
712};
713
714pub mod subscription_router;
715pub use subscription_router::{
716    // FNV-1a helper exposed for downstream use
717    fnv1a_64 as mr_fnv1a_64,
718    // SubscriptionRouter and related types
719    DeliveryRecord,
720    MessageTopic,
721    RoutingMessage,
722    SubRouterStats,
723    Subscription,
724    SubscriptionFilter,
725    SubscriptionRouter,
726};
727
728pub mod request_dedup;
729
730pub use request_dedup::{
731    AcquireResult, DedupStats, DedupStatsSnapshot, RequestDeduplicator, ResolveResult, WaiterHandle,
732};
733
734// Re-export commonly used utility functions
735pub use utils::{
736    exponential_backoff, format_bandwidth, format_bytes, format_duration, is_local_addr,
737    is_public_addr, jittered_backoff, moving_average, parse_multiaddr, parse_multiaddrs,
738    peers_match, percentage, truncate_peer_id, validate_alpha,
739};
740
741pub mod peer_discovery_manager;
742pub use peer_discovery_manager::{
743    ConnectOutcome, DiscoveryConfig as PdmDiscoveryConfig, DiscoveryMethod,
744    DiscoveryStats as PdmDiscoveryStats, PeerCandidate,
745    PeerDiscoveryManager as PdmPeerDiscoveryManager,
746};
747
748pub mod discovery_cache;
749pub use discovery_cache::{DiscoveryCacheStats, DiscoverySource, PeerDiscoveryCache, PeerRecord};
750
751pub mod discovery_lru;
752pub use discovery_lru::{
753    CacheEntry as LruCacheEntry, DiscoveryCacheConfig as LruDiscoveryCacheConfig,
754    LruDiscoveryCacheStats, LruPeerDiscoveryCache,
755};
756
757pub mod circuit_breaker;
758pub use circuit_breaker::{
759    CallResult, CircuitBreakerRegistry, CircuitBreakerState, CircuitConfig, CircuitStats,
760    PeerCircuit, PeerCircuitBreaker, PeerCircuitState, RegistryStats,
761};
762
763pub mod topology_mapper;
764pub use topology_mapper::{
765    // Primary type — aliased to avoid collision with network_topology_mapper::NetworkTopologyMapper.
766    NetworkTopologyMapper as LegacyNetworkTopologyMapper,
767    PathResult,
768    // Legacy aliases kept for backwards compatibility
769    PeerEdge,
770    TopoEdge,
771    TopoNode,
772    TopologyNode,
773    TopologySnapshot,
774    TopologyStats,
775};
776
777pub mod message_dedup;
778pub use message_dedup::{DedupConfig, DedupEntry, MessageDeduplicator, MsgDedupStats, MsgId};
779
780pub mod message_batcher;
781pub use message_batcher::{
782    BatchConfig, BatchFlush, BatchMessage, BatcherStats, FlushReason, PeerMessageBatcher,
783};
784
785pub mod message_codec;
786pub use message_codec::{CodecConfig, CodecError, CodecStats, EncodedMessage, PeerMessageCodec};
787
788pub mod message_prioritizer;
789pub use message_prioritizer::{
790    AgingConfig, MessagePriority as PeerMessagePriority, PeerMessagePrioritizer,
791    PrioritizedMessage as PeerPrioritizedMessage, PrioritizerStats,
792};
793
794pub mod priority_queue;
795pub use priority_queue::{
796    MessagePriority as PeerQueuePriority, PeerPriorityQueue, QueueConfig, QueueStats, QueuedMessage,
797};
798
799pub mod latency_tracker;
800pub use latency_tracker::{
801    LatencyBucket,
802    LatencyTrackerStats,
803    PeerLatency,
804    // Re-export with alias to avoid collision with adaptive_lookup::PeerLatencyTracker.
805    PeerLatencyTracker as HistogramLatencyTracker,
806};
807
808pub mod latency_predictor;
809pub use latency_predictor::{
810    LatencySample, PeerLatencyPredictor, PeerLatencyState, PredictorConfig, PredictorStats,
811    TrendDirection as LatencyTrendDirection,
812};
813
814pub mod peer_session;
815pub use peer_session::{
816    PeerSession as AuthPeerSession, PeerSessionManager as AuthPeerSessionManager,
817    SessionCapability, SessionManagerConfig as AuthSessionManagerConfig, SessionToken,
818};
819
820pub mod session_manager;
821pub use session_manager::{
822    PeerSession, PeerSessionEntry, PeerSessionManager, PeerSessionState, SessionDirection,
823    SessionManagerConfig, SessionManagerStats, SessionState,
824};
825
826pub mod connection_limiter;
827pub use connection_limiter::{
828    LimiterConfig, LimiterStats, PeerConnectionInfo as LimiterPeerConnectionInfo,
829    PeerConnectionLimiter,
830};
831
832pub mod connection_health;
833pub use connection_health::{
834    ConnectionEvent, ConnectionHealthChecker, ConnectionHealthState, ConnectionRecord,
835    HealthCheckerConfig,
836};
837
838pub mod announcement_manager;
839pub use announcement_manager::{
840    AnnouncementChannel, AnnouncementConfig, AnnouncementRecord, AnnouncementStats,
841    PeerAnnouncementManager,
842};
843
844pub mod routing_auditor;
845pub use routing_auditor::{
846    AuditFinding, AuditSeverity, AuditorConfig, BucketInfo as AuditorBucketInfo,
847    RoutingTableAuditor, DEFAULT_MAX_CAPACITY,
848};
849
850pub mod peer_reputation;
851pub use peer_reputation::{
852    PeerReputationManager, PrReputationConfig, PrReputationEvent, PrReputationScore,
853    PrReputationStats,
854};
855
856pub mod ban_list;
857pub use ban_list::{BanConfig, BanEntry, BanKind, BanListStats, PeerBanList};
858
859pub mod behavior_classifier;
860pub use behavior_classifier::{
861    BehaviorProfile, BehaviorSignal, ClassifierStats, PeerBehaviorClassifier,
862};
863
864pub mod sync_coordinator;
865pub use sync_coordinator::{PeerSyncCoordinator, SyncDirection, SyncPhase, SyncSession, SyncStats};
866
867pub mod peer_sync_protocol;
868pub use peer_sync_protocol::{
869    ConflictPolicy, PeerSyncProtocol, PspSyncStats, SyncEntry, SyncError, SyncOperation, SyncState,
870    VectorClock,
871};
872
873pub mod congestion_controller;
874pub use congestion_controller::{
875    CccAlgorithm,
876    CccCongestionController,
877    CccConnId,
878    CccConnection,
879    CccControllerConfig,
880    CccControllerStats,
881    CccDecision,
882    CccEvent,
883    CccEventType,
884    CccState,
885    CongestionConfig,
886    // New multi-algorithm controller.
887    CongestionController,
888    CongestionEvent,
889    CongestionState,
890    Decision,
891    MultiPeerCongestionManager,
892    PeerCongestionController,
893    WindowStats,
894};
895
896pub mod load_balancer;
897pub use load_balancer::{
898    AdaptiveLbStats, AdaptiveLoadBalancer, LbAlgorithm, LbDecision, LbPeer, LbRequest,
899};
900pub use load_balancer::{LbStats, LbStrategy, PeerLoad, PeerLoadBalancer};
901
902pub mod trust_manager;
903pub use trust_manager::{
904    PeerTrustManager, TrustAttestation, TrustLevel, TrustManagerStats, TrustRecord,
905};
906
907pub mod flow_control;
908pub use flow_control::{FlowControlConfig, FlowControlStats, FlowWindow, PeerFlowControl};
909
910pub mod gossip_filter;
911pub use gossip_filter::{
912    FilterConfig, FilterStats, FilterVerdict, GossipMessage as FilterGossipMessage,
913    PeerGossipFilter,
914};
915
916pub mod gossip_content_filter;
917pub use gossip_content_filter::{ContentGossipFilter, FilterAction, FilterRule, GossipFilterStats};
918
919pub mod bloom_filter;
920pub use bloom_filter::{BloomConfig, BloomFilter, BloomStats, PeerBloomFilter};
921
922pub mod churn_manager;
923pub use churn_manager::{
924    ChurnEvent, ChurnManagerConfig, ChurnStats, ChurnWindow, PeerChurnManager, PeerLifetime,
925};
926
927pub mod request_priority_queue;
928pub use request_priority_queue::{
929    PeerRequest, PeerRequestQueue, PriorityQueueStats as RequestQueueStats,
930    RequestPriority as PeerRequestPriority,
931};
932
933pub mod health_checker;
934pub use health_checker::{
935    HealthCheckerStats as PeerHealthCheckerStats,
936    // HealthTier may clash with other tier enums; export with a peer-specific alias.
937    HealthTier as PeerHealthTier,
938    HeartbeatRecord,
939    PeerHealthChecker,
940    PeerHealthCheckerConfig,
941};
942
943pub mod scoreboard;
944pub use scoreboard::{PeerScoreboard, SbPeerScore, ScoreComponent, ScoreboardStats};
945
946pub mod peer_scoring;
947pub use peer_scoring::{
948    PeerMetrics,
949    PeerScoringSystem,
950    // PeerScore already exported from gossipsub; use prefixed alias.
951    PsPeerScore,
952    // ScoreComponent already exported from scoreboard (as a struct); use prefixed alias.
953    PsScoringDimension,
954    ScoreTier,
955    ScoringError,
956    ScoringStats,
957    ScoringWeights,
958};
959
960pub mod overlay_network;
961pub use overlay_network::{
962    OverlayError, OverlayMessage, OverlayNetworkManager, OverlayNode, OverlayRoute, OverlayStats,
963    OverlayTopology,
964};
965
966pub mod overlay_network_manager;
967pub use overlay_network_manager::{
968    fnv1a_64 as onm_fnv1a_64,
969    xorshift64 as onm_xorshift64,
970    // New types with no crate-root collision.
971    OverlayConfig,
972    // Collide with overlay_network exports → Onm prefix.
973    OverlayError as OnmOverlayError,
974    OverlayLink,
975    OverlayNetworkManager as OnmOverlayNetworkManager,
976    OverlayNode as OnmOverlayNode,
977    OverlayStats as OnmOverlayStats,
978    OverlayTopology as OnmOverlayTopology,
979    RoutingPolicy,
980    VirtualRoute,
981};
982
983pub mod flood_protection;
984pub use flood_protection::{
985    fnv1a_message_id,
986    CheckResult as FpCheckResult,
987    FloodConfig,
988    FloodProtection,
989    FloodStats,
990    // Export MessageId with Fp prefix to avoid collision with gossipsub::MessageId.
991    MessageId as FpMessageId,
992    PeerState as FpPeerState,
993    ViolationRecord,
994    ViolationType,
995};
996
997pub mod security_monitor;
998pub use security_monitor::{
999    IncidentStatus, NetworkSecurityMonitor, SecurityEvent, SecurityIncident, SecurityMonitorStats,
1000    ThreatLevel, ThreatScore, ThreatType,
1001};
1002
1003pub mod stream_multiplexer;
1004pub use stream_multiplexer::{
1005    priority_from_u8 as smx_priority_from_u8,
1006    xorshift64 as smx_xorshift64,
1007    FrameFlags,
1008    LogicalStream,
1009    MultiplexerConfig,
1010    MultiplexerStats,
1011    MuxError,
1012    MuxEvent,
1013    MuxStats,
1014    StreamFrame,
1015    // StreamId is already exported from tor; alias to avoid collision.
1016    StreamId as SmxStreamId,
1017    StreamInfo,
1018    StreamMultiplexer,
1019    StreamPriority,
1020    // StreamState is already exported from tor; alias to avoid collision.
1021    StreamState as SmxStreamState,
1022    FLAG_FIN as SMX_FLAG_FIN,
1023    FLAG_RST as SMX_FLAG_RST,
1024    FLAG_SYN as SMX_FLAG_SYN,
1025};
1026
1027pub mod merkle_proof_verifier;
1028pub use merkle_proof_verifier::{
1029    sha256 as mpv_sha256,
1030    MerkleHashAlgo,
1031    MerkleNode,
1032    MerkleProof,
1033    MerkleProofVerifier,
1034    MerkleTree,
1035    ProofStep,
1036    // VerificationResult conflicts with cert_pin::VerificationResult → alias.
1037    VerificationResult as MpvVerificationResult,
1038};
1039
1040pub mod peer_bandwidth_manager;
1041pub use peer_bandwidth_manager::{
1042    BandwidthDirection, BandwidthLimit, BandwidthManagerConfig, BandwidthManagerStats,
1043    BandwidthUsage, FairnessPolicy, PeerBandwidthManager, PeerBandwidthState,
1044};
1045
1046pub mod gossip_message_filter;
1047pub use gossip_message_filter::{
1048    fnv1a_64 as gmf_fnv1a_64,
1049    // FilterConfig conflicts with gossip_filter::FilterConfig → Gmf prefix.
1050    FilterConfig as GmfFilterConfig,
1051    // FilterRule conflicts with gossip_content_filter::FilterRule → Gmf prefix.
1052    FilterRule as GmfFilterRule,
1053    // FilterStats conflicts with gossip_filter::FilterStats → Gmf prefix.
1054    FilterStats as GmfFilterStats,
1055    // FilterVerdict conflicts with gossip_filter::FilterVerdict → Gmf prefix.
1056    FilterVerdict as GmfFilterVerdict,
1057    // GossipMessage conflicts with gossip_overlay::GossipMessage → Gmf prefix.
1058    GossipMessage as GmfGossipMessage,
1059    GossipMessageFilter,
1060    // MessageId conflicts with gossipsub::MessageId → Gmf prefix.
1061    MessageId as GmfMessageId,
1062};
1063
1064pub mod peer_trust_scorer;
1065pub use peer_trust_scorer::{
1066    PeerTrustProfile, PeerTrustScorer, TrustBand, TrustConfig, TrustDimension, TrustEvent,
1067    TrustScorerStats,
1068};
1069
1070pub mod network_event_bus;
1071pub use network_event_bus::{
1072    BusError,
1073    EventBusConfig,
1074    EventBusStats,
1075    EventFilter,
1076    EventTopic,
1077    // NebNetworkEvent is the bus-specific event struct; node::NetworkEvent is
1078    // a different type, so we keep the Neb prefix to avoid collision.
1079    NebNetworkEvent,
1080    // NebSubscription avoids collision with subscription_router::Subscription.
1081    NebSubscription,
1082    NetworkEventBus,
1083    SubscriberId,
1084};
1085
1086pub mod network_qos_manager;
1087pub use network_qos_manager::{
1088    NetworkQoSManager,
1089    QoSConfig,
1090    QoSPacket,
1091    QoSStats,
1092    QueueMetrics,
1093    SLASpec,
1094    SLAViolation,
1095    // TrafficClass conflicts with traffic_shaper::TrafficClass which is not re-exported
1096    // at crate root, so no alias needed here.
1097    TrafficClass as QosTrafficClass,
1098};
1099
1100pub mod flood_sub_router;
1101pub use flood_sub_router::{
1102    FloodMessage,
1103    FloodMessageId,
1104    FloodSubRouter,
1105    FloodTopic,
1106    ForwardDecision,
1107    // FsrRouterStats is already prefixed to avoid collision with
1108    // message_router::RouterStats which is exported as RouterStats.
1109    FsrRouterStats,
1110    // RouterConfig conflicts with nothing at crate root → no alias needed.
1111    RouterConfig as FsrRouterConfig,
1112    SubscriptionRecord as FsrSubscriptionRecord,
1113};
1114
1115pub mod peer_reputation_graph;
1116pub use peer_reputation_graph::{
1117    GraphConfig,
1118    GraphError,
1119    GraphStats,
1120    PeerReputationGraph,
1121    // ReputationEvent collides with reputation::ReputationEvent → Prg prefix.
1122    ReputationEvent as PrgReputationEvent,
1123    // ReputationScore collides with reputation::ReputationScore → Prg prefix.
1124    ReputationScore as PrgReputationScore,
1125    TrustEdge,
1126};
1127
1128pub mod gossip_protocol_engine;
1129pub use gossip_protocol_engine::{
1130    fnv1a_64 as gpe_fnv1a_64,
1131    xorshift64 as gpe_xorshift64,
1132    EngineError,
1133    FanoutStrategy,
1134    GossipConfig,
1135    // GossipEvent conflicts with gossip_metrics::GossipEvent → Gpe prefix.
1136    GossipEvent as GpeGossipEvent,
1137    // GossipMessage conflicts with gossip_overlay::GossipMessage → Gpe prefix.
1138    GossipMessage as GpeGossipMessage,
1139    GossipPeer,
1140    GossipProtocolEngine,
1141    // GossipStats conflicts with gossip_overlay::GossipStats → Gpe prefix.
1142    GossipStats as GpeGossipStats,
1143};
1144
1145pub mod network_circuit_breaker;
1146pub use network_circuit_breaker::{
1147    xorshift64 as ncb_xorshift64,
1148    BreakerError,
1149    CircuitCallGuard,
1150    CircuitEvent,
1151    CircuitMetrics,
1152    CircuitOutcome,
1153    // CircuitConfig collides with circuit_breaker::CircuitConfig → Ncb prefix.
1154    NcbCircuitConfig,
1155    // CircuitState collides with tor::CircuitState → Ncb prefix.
1156    NcbCircuitState,
1157    NetworkCircuitBreaker,
1158};
1159
1160pub mod peer_discovery_protocol;
1161pub use peer_discovery_protocol::{
1162    // PRNG helper (aliased to avoid collision with other xorshift64 exports).
1163    xorshift64 as pdp_xorshift64,
1164    // Type aliases (unprefixed) — no collision at crate root.
1165    DiscoveredPeer,
1166    DiscoveryConfig,
1167    DiscoveryError,
1168    DiscoveryEvent,
1169    DiscoveryStats,
1170    // Core structs and enums with Pdp prefix (canonical names).
1171    PdpDiscoveredPeer,
1172    PdpDiscoveryConfig,
1173    PdpDiscoveryError,
1174    PdpDiscoveryEvent,
1175    PdpDiscoveryMethod,
1176    PdpDiscoveryStats,
1177    PeerDiscoveryProtocol,
1178};
1179
1180pub mod message_authenticator;
1181pub use message_authenticator::{
1182    fnv1a_64 as mau_fnv1a_64, hmac_fnv64 as mau_hmac_fnv64, xorshift64 as mau_xorshift64,
1183    AuthAlgorithm, AuthError, AuthKey, AuthPolicy, AuthStats, MessageAuthenticator, ReplayWindow,
1184    SignedMessage,
1185};
1186
1187pub mod connection_pool_manager;
1188pub use connection_pool_manager::{
1189    xorshift64 as cpm_xorshift64,
1190    AcquirePolicy,
1191    ConnState,
1192    ConnectionPoolManager,
1193    // PoolConfig collides with connection_pool::PoolConfig → Cpm prefix.
1194    CpmPoolConfig,
1195    // PoolError collides with connection_pool::PoolError → Cpm prefix.
1196    CpmPoolError,
1197    // PoolStats collides with connection_pool::PoolStats → Cpm prefix.
1198    CpmPoolStats,
1199    PoolEvent,
1200    // PooledConnection collides with connection_pool::PooledConnection → Cpm prefix.
1201    PooledConnection as CpmPooledConnection,
1202};
1203
1204pub mod adaptive_routing_engine;
1205pub use adaptive_routing_engine::{
1206    AdaptiveRoutingEngine,
1207    AreRouteEntry,
1208    AreRouteKey,
1209    AreRoutingConfig,
1210    // RoutingPolicy is already exported from overlay_network_manager → use Are prefix.
1211    AreRoutingPolicy,
1212    AreRoutingStats,
1213    RoutingEngineError,
1214};
1215
1216pub mod peer_load_balancer;
1217pub use peer_load_balancer::{
1218    // PeerLoadBalancer collides with load_balancer::PeerLoadBalancer → Plb prefix.
1219    PeerLoadBalancer as PlbPeerLoadBalancer,
1220    PlbBalancerConfig,
1221    PlbBalancerStats,
1222    PlbError,
1223    PlbPeerId,
1224    PlbPeerState,
1225    PlbPeerStats,
1226    PlbRequestRecord,
1227    PlbStrategy,
1228};
1229
1230pub mod network_topology_mapper;
1231pub use network_topology_mapper::{
1232    NetworkTopologyMapper, NtmEdge, NtmMapperConfig, NtmMapperError, NtmNetworkTopologyMapper,
1233    NtmNode, NtmSnapshot, NtmTopologyMetrics,
1234};
1235
1236pub mod stream_priority_scheduler;
1237pub use stream_priority_scheduler::{
1238    xorshift64 as sps_xorshift64, SpsError, SpsSchedulerConfig, SpsSchedulerStats,
1239    SpsSchedulingPolicy, SpsStream, SpsStreamId, StreamPriorityScheduler,
1240};
1241
1242pub mod packet_fragmentation_assembler;
1243pub use packet_fragmentation_assembler::{
1244    fnv1a_64 as pfa_fnv1a_64, xorshift64 as pfa_xorshift64, PacketFragmentationAssembler,
1245    PfaAssemblerConfig, PfaAssemblerStats, PfaFragment, PfaFragmentRecord, PfaMessageId,
1246    PfaPacketFragmentationAssembler, PfaReassemblyBuffer, PfaReceiveResult,
1247};
1248
1249/// Re-export libp2p types
1250pub use libp2p;