[−][src]Struct tari_comms::PeerManager
The PeerManager consist of a routing table of previously discovered peers. It also provides functionality to add, find and delete peers.
Implementations
impl PeerManager
[src]
pub fn new(database: CommsDatabase) -> Result<PeerManager, PeerManagerError>
[src]
Constructs a new empty PeerManager
pub fn migrate_lmdb(database: &LMDBDatabase) -> Result<(), PeerManagerError>
[src]
Migrate the peer database, this only applies to the LMDB database
pub async fn count<'_>(&'_ self) -> usize
[src]
pub async fn add_peer<'_>(
&'_ self,
peer: Peer
) -> Result<PeerId, PeerManagerError>
[src]
&'_ self,
peer: Peer
) -> Result<PeerId, PeerManagerError>
Adds a peer to the routing table of the PeerManager if the peer does not already exist. When a peer already exist, the stored version will be replaced with the newly provided peer.
pub async fn delete_peer<'_, '_>(
&'_ self,
node_id: &'_ NodeId
) -> Result<(), PeerManagerError>
[src]
&'_ self,
node_id: &'_ NodeId
) -> Result<(), PeerManagerError>
The peer with the specified public_key will be removed from the PeerManager
pub async fn perform_query<'_, '_>(
&'_ self,
peer_query: PeerQuery<'_>
) -> Result<Vec<Peer>, PeerManagerError>
[src]
&'_ self,
peer_query: PeerQuery<'_>
) -> Result<Vec<Peer>, PeerManagerError>
Performs the given PeerQuery.
pub async fn find_by_node_id<'_, '_>(
&'_ self,
node_id: &'_ NodeId
) -> Result<Peer, PeerManagerError>
[src]
&'_ self,
node_id: &'_ NodeId
) -> Result<Peer, PeerManagerError>
Find the peer with the provided NodeID
pub async fn find_by_public_key<'_, '_>(
&'_ self,
public_key: &'_ CommsPublicKey
) -> Result<Peer, PeerManagerError>
[src]
&'_ self,
public_key: &'_ CommsPublicKey
) -> Result<Peer, PeerManagerError>
Find the peer with the provided PublicKey
pub async fn exists<'_, '_>(&'_ self, public_key: &'_ CommsPublicKey) -> bool
[src]
Check if a peer exist using the specified public_key
pub async fn exists_node_id<'_, '_>(&'_ self, node_id: &'_ NodeId) -> bool
[src]
Check if a peer exist using the specified node_id
pub async fn all<'_>(&'_ self) -> Result<Vec<Peer>, PeerManagerError>
[src]
Returns all peers
pub async fn add_or_update_online_peer<'_, '_>(
&'_ self,
pubkey: &'_ CommsPublicKey,
node_id: NodeId,
addresses: Vec<Multiaddr>,
peer_features: PeerFeatures
) -> Result<Peer, PeerManagerError>
[src]
&'_ self,
pubkey: &'_ CommsPublicKey,
node_id: NodeId,
addresses: Vec<Multiaddr>,
peer_features: PeerFeatures
) -> Result<Peer, PeerManagerError>
Adds or updates a peer and sets the last connection as successful. If the peer is marked as offline, it will be unmarked.
pub async fn direct_identity_node_id<'_, '_>(
&'_ self,
node_id: &'_ NodeId
) -> Result<Option<Peer>, PeerManagerError>
[src]
&'_ self,
node_id: &'_ NodeId
) -> Result<Option<Peer>, PeerManagerError>
Get a peer matching the given node ID
pub async fn direct_identity_public_key<'_, '_>(
&'_ self,
public_key: &'_ CommsPublicKey
) -> Result<Option<Peer>, PeerManagerError>
[src]
&'_ self,
public_key: &'_ CommsPublicKey
) -> Result<Option<Peer>, PeerManagerError>
Get a peer matching the given public key
pub async fn flood_peers<'_>(&'_ self) -> Result<Vec<Peer>, PeerManagerError>
[src]
Fetch all peers (except banned ones)
pub async fn for_each<F, '_>(&'_ self, f: F) -> Result<(), PeerManagerError> where
F: FnMut(Peer) -> IterationResult,
[src]
F: FnMut(Peer) -> IterationResult,
pub async fn closest_peers<'_, '_, '_>(
&'_ self,
node_id: &'_ NodeId,
n: usize,
excluded_peers: &'_ [CommsPublicKey],
features: Option<PeerFeatures>
) -> Result<Vec<Peer>, PeerManagerError>
[src]
&'_ self,
node_id: &'_ NodeId,
n: usize,
excluded_peers: &'_ [CommsPublicKey],
features: Option<PeerFeatures>
) -> Result<Vec<Peer>, PeerManagerError>
Fetch n nearest neighbours. If features are supplied, the function will return the closest peers matching that feature
pub async fn random_peers<'_, '_>(
&'_ self,
n: usize,
excluded: &'_ [NodeId]
) -> Result<Vec<Peer>, PeerManagerError>
[src]
&'_ self,
n: usize,
excluded: &'_ [NodeId]
) -> Result<Vec<Peer>, PeerManagerError>
Fetch n random peers
pub async fn in_network_region<'_, '_, '_>(
&'_ self,
node_id: &'_ NodeId,
region_node_id: &'_ NodeId,
n: usize
) -> Result<bool, PeerManagerError>
[src]
&'_ self,
node_id: &'_ NodeId,
region_node_id: &'_ NodeId,
n: usize
) -> Result<bool, PeerManagerError>
Check if a specific node_id is in the network region of the N nearest neighbours of the region specified by region_node_id
pub async fn calc_region_threshold<'_, '_>(
&'_ self,
region_node_id: &'_ NodeId,
n: usize,
features: PeerFeatures
) -> Result<NodeDistance, PeerManagerError>
[src]
&'_ self,
region_node_id: &'_ NodeId,
n: usize,
features: PeerFeatures
) -> Result<NodeDistance, PeerManagerError>
pub async fn unban_peer<'_, '_>(
&'_ self,
node_id: &'_ NodeId
) -> Result<(), PeerManagerError>
[src]
&'_ self,
node_id: &'_ NodeId
) -> Result<(), PeerManagerError>
Unbans the peer if it is banned. This function is idempotent.
pub async fn ban_peer<'_, '_>(
&'_ self,
public_key: &'_ CommsPublicKey,
duration: Duration
) -> Result<NodeId, PeerManagerError>
[src]
&'_ self,
public_key: &'_ CommsPublicKey,
duration: Duration
) -> Result<NodeId, PeerManagerError>
Ban the peer for a length of time specified by the duration
pub async fn ban_peer_by_node_id<'_, '_>(
&'_ self,
node_id: &'_ NodeId,
duration: Duration
) -> Result<NodeId, PeerManagerError>
[src]
&'_ self,
node_id: &'_ NodeId,
duration: Duration
) -> Result<NodeId, PeerManagerError>
Ban the peer for a length of time specified by the duration
pub async fn set_offline<'_, '_>(
&'_ self,
node_id: &'_ NodeId,
is_offline: bool
) -> Result<NodeId, PeerManagerError>
[src]
&'_ self,
node_id: &'_ NodeId,
is_offline: bool
) -> Result<NodeId, PeerManagerError>
Changes the offline flag bit of the peer
pub async fn add_net_address<'_, '_, '_>(
&'_ self,
node_id: &'_ NodeId,
net_address: &'_ Multiaddr
) -> Result<(), PeerManagerError>
[src]
&'_ self,
node_id: &'_ NodeId,
net_address: &'_ Multiaddr
) -> Result<(), PeerManagerError>
Adds a new net address to the peer if it doesn't yet exist
pub async fn update_each<F, '_>(
&'_ self,
__arg1: F
) -> Result<usize, PeerManagerError> where
F: FnMut(Peer) -> Option<Peer>,
[src]
&'_ self,
__arg1: F
) -> Result<usize, PeerManagerError> where
F: FnMut(Peer) -> Option<Peer>,
pub async fn get_peer_features<'_, '_>(
&'_ self,
node_id: &'_ NodeId
) -> Result<PeerFeatures, PeerManagerError>
[src]
&'_ self,
node_id: &'_ NodeId
) -> Result<PeerFeatures, PeerManagerError>
Auto Trait Implementations
impl !RefUnwindSafe for PeerManager
impl Send for PeerManager
impl Sync for PeerManager
impl Unpin for PeerManager
impl !UnwindSafe for PeerManager
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> Cast<U> for T where
U: FromCast<T>,
U: FromCast<T>,
fn cast(self) -> U
impl<T> From<T> for T
[src]
impl<T> FromBits<T> for T
fn from_bits(t: T) -> T
impl<T> FromCast<T> for T
fn from_cast(t: T) -> T
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> IntoBits<U> for T where
U: FromBits<T>,
U: FromBits<T>,
fn into_bits(self) -> U
impl<T> SafeBorrow<T> for T where
T: ?Sized,
T: ?Sized,
fn borrow_replacement(ptr: &T) -> &T
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,