Struct PeerStore

Source
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

Source

pub fn load_from_dir_or_default<P: AsRef<Path>>(path: P) -> Self

Init peer store from disk

Source

pub fn dump_to_dir<P: AsRef<Path>>(&self, path: P) -> Result<(), Error>

Dump all info to disk

Source§

impl PeerStore

Source

pub fn new(addr_manager: AddrManager, ban_list: BanList) -> Self

New with address list and ban list

Source

pub fn add_connected_peer(&mut self, addr: Multiaddr, session_type: SessionType)

this method will assume peer is connected, which implies address is “verified”.

Source

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.

Source

pub fn add_outbound_addr(&mut self, addr: Multiaddr, flags: Flags)

Add outbound peer address

Source

pub fn update_outbound_addr_last_connected_ms(&mut self, addr: Multiaddr)

Update outbound peer last connected ms

Source

pub fn addr_manager(&self) -> &AddrManager

Get address manager

Source

pub fn mut_addr_manager(&mut self) -> &mut AddrManager

Get mut address manager

Source

pub fn report(&mut self, addr: &Multiaddr, behaviour: Behaviour) -> ReportResult

Report peer behaviours

Source

pub fn remove_disconnected_peer(&mut self, addr: &Multiaddr) -> Option<PeerInfo>

Remove peer id

Source

pub fn peer_status(&self, peer_id: &PeerId) -> Status

Get peer status

Source

pub fn fetch_addrs_to_attempt<F>( &mut self, count: usize, required_flags: Flags, filter: F, ) -> Vec<AddrInfo>
where F: Fn(&AddrInfo) -> bool,

Get peers for outbound connection, this method randomly return recently connected peer addrs

Source

pub fn fetch_addrs_to_feeler<F>( &mut self, count: usize, filter: F, ) -> Vec<AddrInfo>
where F: Fn(&AddrInfo) -> bool,

Get peers for feeler connection, this method randomly return peer addrs that we never connected to.

Source

pub fn fetch_random_addrs( &mut self, count: usize, required_flags: Flags, ) -> Vec<AddrInfo>

Return valid addrs that success connected, used for discovery.

Source

pub fn is_addr_banned(&self, addr: &Multiaddr) -> bool

Whether the address is banned

Source

pub fn ban_list(&self) -> &BanList

Get ban list

Source

pub fn mut_ban_list(&mut self) -> &mut BanList

Get mut ban list

Source

pub fn clear_ban_list(&mut self)

Clear ban list

Trait Implementations§

Source§

impl Default for PeerStore

Source§

fn default() -> PeerStore

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Cast to trait Any
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,