pub struct PeerStore { /* private fields */ }Implementations§
Source§impl PeerStore
impl PeerStore
pub fn new() -> Self
pub async fn insert(&self, addr: SocketAddr, source: PeerSource)
pub async fn bulk_insert<I: IntoIterator<Item = SocketAddr>>( &self, it: I, source: PeerSource, )
pub async fn mark_success(&self, addr: &SocketAddr)
Sourcepub async fn mark_success_with_meta(
&self,
addr: &SocketAddr,
node_id: Option<String>,
capabilities: Option<Vec<String>>,
)
pub async fn mark_success_with_meta( &self, addr: &SocketAddr, node_id: Option<String>, capabilities: Option<Vec<String>>, )
Mark peer as successfully connected and update metadata from HELLO
pub async fn mark_failure(&self, addr: &SocketAddr)
Sourcepub async fn next_reconnect_attempt(
&self,
addr: &SocketAddr,
max_attempts: u32,
) -> Option<u32>
pub async fn next_reconnect_attempt( &self, addr: &SocketAddr, max_attempts: u32, ) -> Option<u32>
Reserve the next reconnect attempt number, starting at one.
Returns None when the configured consecutive-attempt budget is exhausted.
pub async fn reset_reconnect(&self, addr: &SocketAddr)
pub async fn reconnect_attempts(&self, addr: &SocketAddr) -> u32
pub async fn sample( &self, k: usize, exclude: &HashSet<SocketAddr>, ) -> Vec<SocketAddr>
pub async fn all(&self) -> Vec<SocketAddr>
pub async fn load_from_file( path: &str, ttl_secs: u64, max_entries: usize, ) -> Self
pub async fn save_to_file(&self, path: &str) -> Result<(), Error>
pub async fn spawn_periodic_save(self, path: String, interval_secs: u64)
Sourcepub async fn from_config(cfg: &Config) -> Self
pub async fn from_config(cfg: &Config) -> Self
Construct and optionally start periodic saves based on runtime config.
Uses node.state_dir to derive path when not explicitly provided.
Sourcepub async fn save_if_enabled(&self, cfg: &Config)
pub async fn save_if_enabled(&self, cfg: &Config)
Save to derived path if persistence enabled in config.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for PeerStore
impl !UnwindSafe for PeerStore
impl Freeze for PeerStore
impl Send for PeerStore
impl Sync for PeerStore
impl Unpin for PeerStore
impl UnsafeUnpin for PeerStore
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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