1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright 2024 Saorsa Labs Ltd.
//
// This Saorsa Network Software is licensed under the General Public License (GPL), version 3.
// Please see the file LICENSE-GPL, or visit <http://www.gnu.org/licenses/> for the full text.
//
// Full details available at https://saorsalabs.com/licenses
//! Greedy Bootstrap Cache
//!
//! Provides persistent peer caching with quality-based selection for network bootstrap.
//!
//! ## Features
//!
//! - **Large capacity**: 10,000-30,000 peer entries (configurable)
//! - **Quality scoring**: Success rate, RTT, age decay, capability bonuses
//! - **Epsilon-greedy selection**: Balances exploitation vs exploration
//! - **Multi-process safe**: Atomic writes with file locking (Unix)
//! - **Background maintenance**: Periodic save, cleanup, and quality updates
//!
//! ## Example
//!
//! ```rust,ignore
//! use ant_quic::bootstrap_cache::{BootstrapCache, BootstrapCacheConfig};
//! use std::sync::Arc;
//!
//! #[tokio::main]
//! async fn main() -> anyhow::Result<()> {
//! let config = BootstrapCacheConfig::builder()
//! .cache_dir("/var/lib/ant-quic")
//! .max_peers(20_000)
//! .epsilon(0.1)
//! .build();
//!
//! let cache = Arc::new(BootstrapCache::open(config).await?);
//!
//! // Start background maintenance
//! let _maintenance = cache.clone().start_maintenance();
//!
//! // Get peers for bootstrap (epsilon-greedy selection)
//! let peers = cache.select_peers(50).await;
//!
//! // Record connection results
//! for peer in &peers {
//! // ... attempt connection ...
//! cache.record_success(&peer.peer_id, 100).await; // or record_failure
//! }
//!
//! // Save periodically (also done by maintenance task)
//! cache.save().await?;
//!
//! Ok(())
//! }
//! ```
pub use ;
pub use ;
pub use ;
pub use EncryptedCachePersistence;
pub use SelectionStrategy;
pub use BootstrapTokenStore;