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( &mut self, count: usize, required_flags: Flags ) -> Vec<AddrInfo>

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

source

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

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AsAny for Twhere T: Any,

§

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

TODO(doc): @quake
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

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

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

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

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more