Struct fuel_core_p2p::peer_manager::PeerManager
source · pub struct PeerManager { /* private fields */ }
Expand description
Manages Peers and their events
Implementations§
source§impl PeerManager
impl PeerManager
pub fn new( reserved_peers_updates: Sender<usize>, reserved_peers: HashSet<PeerId>, connection_state: Arc<RwLock<ConnectionState>>, max_non_reserved_peers: usize, ) -> Self
pub fn reserved_peers_updates(&self) -> Sender<usize>
pub fn is_reserved(&self, peer_id: &PeerId) -> bool
pub fn handle_gossip_score_update<T: Punisher>( &self, peer_id: PeerId, gossip_score: f64, punisher: &mut T, )
pub fn handle_peer_info_updated( &mut self, peer_id: &PeerId, block_height: BlockHeight, )
sourcepub fn handle_peer_connected(&mut self, peer_id: &PeerId) -> bool
pub fn handle_peer_connected(&mut self, peer_id: &PeerId) -> bool
Returns true
signaling that the peer should be disconnected
pub fn handle_peer_identified( &mut self, peer_id: &PeerId, addresses: Vec<Multiaddr>, agent_version: String, )
pub fn batch_update_score_with_decay(&mut self)
pub fn update_app_score<T: Punisher>( &mut self, peer_id: PeerId, score: AppScore, reporting_service: &str, punisher: &mut T, )
pub fn total_peers_connected(&self) -> usize
pub fn get_peers_ids(&self) -> impl Iterator<Item = &PeerId>
pub fn get_peer_info(&self, peer_id: &PeerId) -> Option<&PeerInfo>
pub fn get_all_peers(&self) -> impl Iterator<Item = (&PeerId, &PeerInfo)>
sourcepub fn handle_peer_disconnect(&mut self, peer_id: PeerId) -> bool
pub fn handle_peer_disconnect(&mut self, peer_id: PeerId) -> bool
Handles on peer’s last connection getting disconnected Returns ‘true’ signaling we should try reconnecting
sourcepub fn get_peer_id_with_height(&self, height: &BlockHeight) -> Option<PeerId>
pub fn get_peer_id_with_height(&self, height: &BlockHeight) -> Option<PeerId>
Find a peer that is holding the given block height.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PeerManager
impl !RefUnwindSafe for PeerManager
impl Send for PeerManager
impl Sync for PeerManager
impl Unpin for PeerManager
impl !UnwindSafe for PeerManager
Blanket Implementations§
source§impl<T> AnyDebug for T
impl<T> AnyDebug for T
source§fn as_any_ref(&self) -> &(dyn Any + 'static)
fn as_any_ref(&self) -> &(dyn Any + 'static)
Returns a reference to the underlying type as
Any
.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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§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>
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 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>
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 moresource§impl<S> IteratorOverTable for S
impl<S> IteratorOverTable for S
source§fn iter_all<M>(
&self,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>where
M: Mappable,
Self: IterableTable<M>,
fn iter_all<M>(
&self,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>where
M: Mappable,
Self: IterableTable<M>,
Returns an iterator over the all entries in the table.
source§fn iter_all_by_prefix<M, P>(
&self,
prefix: Option<P>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>
fn iter_all_by_prefix<M, P>( &self, prefix: Option<P>, ) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>
Returns an iterator over the all entries in the table with the specified prefix.
source§fn iter_all_by_start<M>(
&self,
start: Option<&<M as Mappable>::Key>,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>where
M: Mappable,
Self: IterableTable<M>,
fn iter_all_by_start<M>(
&self,
start: Option<&<M as Mappable>::Key>,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>where
M: Mappable,
Self: IterableTable<M>,
Returns an iterator over the all entries in the table after a specific start key.
source§fn iter_all_filtered<M, P>(
&self,
prefix: Option<P>,
start: Option<&<M as Mappable>::Key>,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>
fn iter_all_filtered<M, P>( &self, prefix: Option<P>, start: Option<&<M as Mappable>::Key>, direction: Option<IterDirection>, ) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>
Returns an iterator over the all entries in the table with a prefix after a specific start key.