pub struct BootstrapCache { /* private fields */ }
Expand description
Main bootstrap cache implementation
Implementations§
Source§impl BootstrapCache
impl BootstrapCache
Sourcepub async fn new(cache_dir: PathBuf, config: CacheConfig) -> Result<Self>
pub async fn new(cache_dir: PathBuf, config: CacheConfig) -> Result<Self>
Create a new bootstrap cache
Sourcepub async fn get_bootstrap_peers(
&self,
count: usize,
) -> Result<Vec<ContactEntry>>
pub async fn get_bootstrap_peers( &self, count: usize, ) -> Result<Vec<ContactEntry>>
Get bootstrap peers for initial connection
Sourcepub async fn add_contact(&mut self, contact: ContactEntry) -> Result<()>
pub async fn add_contact(&mut self, contact: ContactEntry) -> Result<()>
Add or update a contact
Sourcepub async fn update_contact_metrics(
&mut self,
peer_id: &PeerId,
metrics: QualityMetrics,
) -> Result<()>
pub async fn update_contact_metrics( &mut self, peer_id: &PeerId, metrics: QualityMetrics, ) -> Result<()>
Update contact metrics
Sourcepub async fn update_quality_scores(&self) -> Result<()>
pub async fn update_quality_scores(&self) -> Result<()>
Update quality scores for all contacts
Sourcepub async fn cleanup_stale_entries(&self) -> Result<()>
pub async fn cleanup_stale_entries(&self) -> Result<()>
Clean up stale entries
Sourcepub async fn get_all_contacts(&self) -> HashMap<PeerId, ContactEntry>
pub async fn get_all_contacts(&self) -> HashMap<PeerId, ContactEntry>
Get all contacts (for merge operations)
Sourcepub async fn set_all_contacts(&self, contacts: HashMap<PeerId, ContactEntry>)
pub async fn set_all_contacts(&self, contacts: HashMap<PeerId, ContactEntry>)
Set all contacts (for merge operations)
Sourcepub async fn get_stats(&self) -> Result<CacheStats>
pub async fn get_stats(&self) -> Result<CacheStats>
Get cache statistics
Sourcepub async fn save_to_disk(&self) -> Result<()>
pub async fn save_to_disk(&self) -> Result<()>
Save cache to disk
Trait Implementations§
Source§impl Clone for BootstrapCache
impl Clone for BootstrapCache
Source§fn clone(&self) -> BootstrapCache
fn clone(&self) -> BootstrapCache
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for BootstrapCache
impl !RefUnwindSafe for BootstrapCache
impl Send for BootstrapCache
impl Sync for BootstrapCache
impl Unpin for BootstrapCache
impl !UnwindSafe for BootstrapCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more