pub struct PeerStore { /* private fields */ }Expand description
Peer store
| – choose to identify –| — choose to feeler — | – delete – | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | More than seven days |
Implementations§
Source§impl PeerStore
impl PeerStore
Sourcepub fn new(addr_manager: AddrManager, ban_list: BanList) -> Self
pub fn new(addr_manager: AddrManager, ban_list: BanList) -> Self
New with address list and ban list
Sourcepub fn add_connected_peer(&mut self, addr: Multiaddr, session_type: SessionType)
pub fn add_connected_peer(&mut self, addr: Multiaddr, session_type: SessionType)
this method will assume peer is connected, which implies address is “verified”.
Sourcepub fn add_addr(&mut self, addr: Multiaddr, flags: Flags) -> Result<()>
pub fn add_addr(&mut self, addr: Multiaddr, flags: Flags) -> Result<()>
Add discovered peer address this method will assume peer and addr is untrust since we have not connected to it.
Sourcepub fn add_outbound_addr(&mut self, addr: Multiaddr, flags: Flags)
pub fn add_outbound_addr(&mut self, addr: Multiaddr, flags: Flags)
Add outbound peer address
Sourcepub fn update_outbound_addr_last_connected_ms(&mut self, addr: Multiaddr)
pub fn update_outbound_addr_last_connected_ms(&mut self, addr: Multiaddr)
Update outbound peer last connected ms
Sourcepub fn addr_manager(&self) -> &AddrManager
pub fn addr_manager(&self) -> &AddrManager
Get address manager
Sourcepub fn mut_addr_manager(&mut self) -> &mut AddrManager
pub fn mut_addr_manager(&mut self) -> &mut AddrManager
Get mut address manager
Sourcepub fn report(&mut self, addr: &Multiaddr, behaviour: Behaviour) -> ReportResult
pub fn report(&mut self, addr: &Multiaddr, behaviour: Behaviour) -> ReportResult
Report peer behaviours
Sourcepub fn remove_disconnected_peer(&mut self, addr: &Multiaddr) -> Option<PeerInfo>
pub fn remove_disconnected_peer(&mut self, addr: &Multiaddr) -> Option<PeerInfo>
Remove peer id
Sourcepub fn peer_status(&self, peer_id: &PeerId) -> Status
pub fn peer_status(&self, peer_id: &PeerId) -> Status
Get peer status
Sourcepub fn fetch_addrs_to_attempt<F>(
&mut self,
count: usize,
required_flags: Flags,
filter: F,
) -> Vec<AddrInfo>
pub fn fetch_addrs_to_attempt<F>( &mut self, count: usize, required_flags: Flags, filter: F, ) -> Vec<AddrInfo>
Get peers for outbound connection, this method randomly return recently connected peer addrs
Sourcepub fn fetch_addrs_to_feeler<F>(
&mut self,
count: usize,
filter: F,
) -> Vec<AddrInfo>
pub fn fetch_addrs_to_feeler<F>( &mut self, count: usize, filter: F, ) -> Vec<AddrInfo>
Get peers for feeler connection, this method randomly return peer addrs that we never connected to.
Sourcepub fn fetch_random_addrs(
&mut self,
count: usize,
required_flags: Flags,
) -> Vec<AddrInfo>
pub fn fetch_random_addrs( &mut self, count: usize, required_flags: Flags, ) -> Vec<AddrInfo>
Return valid addrs that success connected, used for discovery.
Sourcepub fn is_addr_banned(&self, addr: &Multiaddr) -> bool
pub fn is_addr_banned(&self, addr: &Multiaddr) -> bool
Whether the address is banned
Sourcepub fn mut_ban_list(&mut self) -> &mut BanList
pub fn mut_ban_list(&mut self) -> &mut BanList
Get mut ban list
Sourcepub fn clear_ban_list(&mut self)
pub fn clear_ban_list(&mut self)
Clear ban list
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PeerStore
impl RefUnwindSafe for PeerStore
impl Send for PeerStore
impl Sync for PeerStore
impl Unpin for PeerStore
impl UnwindSafe for PeerStore
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
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