pub struct PeerTracker { /* private fields */ }Expand description
The client’s local view of the known peer set and the entry point for Kademlia-style routing.
PeerTracker owns the in-memory list of Peer records the client has seen, persists
them to ClientStorage under BUCKET_PEER so they survive restarts, and exposes the
iteration primitives used throughout the client when it needs to answer “who should I
talk to next about this Id?”. When the list is empty (first launch, or after a
reset), it seeds itself via a BootstrapV1 RPC against the
[crate::transport::bootstrap_provider::BootstrapProvider] addresses configured on the
transport.
The tracker is the single source of truth for peer freshness: stale or bad peers get
evicted here, new peers get folded in here, and the peers_need_flush flag coalesces
rapid updates into a single disk write.
Implementations§
Source§impl PeerTracker
impl PeerTracker
pub async fn new( runtime_services: Arc<RuntimeServices>, client_storage: Arc<dyn ClientStorage>, ) -> Result<Self>
pub async fn flush(&mut self) -> Result<()>
pub fn add_peer(&mut self, peer: Peer) -> Result<()>
pub fn remove_peer(&mut self, peer: &Peer)
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
pub fn peers(&self) -> &Vec<Peer>
pub async fn iterate_to_location( &mut self, bucket_location_id: Id, max_iterations_since_high_watermark: usize, cache_radius: Option<LeadingAgreementBits>, ) -> Result<PeerIterator<'_>>
pub async fn bootstrap(&mut self) -> Result<()>
Auto Trait Implementations§
impl Freeze for PeerTracker
impl !RefUnwindSafe for PeerTracker
impl Send for PeerTracker
impl Sync for PeerTracker
impl Unpin for PeerTracker
impl UnsafeUnpin for PeerTracker
impl !UnwindSafe for PeerTracker
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more