Struct grin_p2p::types::PeerInfo

source ·
pub struct PeerInfo {
    pub capabilities: Capabilities,
    pub user_agent: String,
    pub version: ProtocolVersion,
    pub addr: PeerAddr,
    pub direction: Direction,
    pub live_info: Arc<RwLock<PeerLiveInfo>>,
}
Expand description

General information about a connected peer that’s useful to other modules.

Fields§

§capabilities: Capabilities§user_agent: String§version: ProtocolVersion§addr: PeerAddr§direction: Direction§live_info: Arc<RwLock<PeerLiveInfo>>

Implementations§

source§

impl PeerInfo

source

pub fn total_difficulty(&self) -> Difficulty

The current total_difficulty of the peer.

source

pub fn is_outbound(&self) -> bool

source

pub fn is_inbound(&self) -> bool

source

pub fn height(&self) -> u64

The current height of the peer.

source

pub fn last_seen(&self) -> DateTime<Utc>

Time of last_seen for this peer (via ping/pong).

source

pub fn first_seen(&self) -> DateTime<Utc>

Time of first_seen for this peer.

source

pub fn update(&self, height: u64, total_difficulty: Difficulty)

Update the total_difficulty, height and last_seen of the peer. Takes a write lock on the live_info.

Trait Implementations§

source§

impl Clone for PeerInfo

source§

fn clone(&self) -> PeerInfo

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for PeerInfo

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<PeerInfo> for PeerInfoDisplay

source§

fn from(info: PeerInfo) -> PeerInfoDisplay

Converts to this type from the input type.

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> 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> CloneAny for T
where T: Any + Clone,

source§

fn clone_any(&self) -> Box<dyn CloneAny>

source§

fn clone_any_send(&self) -> Box<dyn CloneAny + Send>
where T: Send,

source§

fn clone_any_sync(&self) -> Box<dyn CloneAny + Sync>
where T: Sync,

source§

fn clone_any_send_sync(&self) -> Box<dyn CloneAny + Send + Sync>
where T: Send + Sync,

source§

impl<'a, T> DefaultFeatures<'a> for T
where T: 'a + Send + Sync + Clone,

source§

fn clone_boxed(&self) -> Box<dyn DefaultFeatures<'a>>

Clone this value, and then immediately put it into a Box behind a trait object of this trait.
source§

fn self_address_mut(&mut self) -> *mut ()

Returns the address of self. 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<'a, T> NonSyncFeatures<'a> for T
where T: 'a + Clone,

source§

fn clone_boxed(&self) -> Box<dyn NonSyncFeatures<'a>>

Clone this value, and then immediately put it into a Box behind a trait object of this trait.
source§

fn self_address_mut(&mut self) -> *mut ()

Returns the address of self. Read more
source§

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

source§

fn borrow_replacement(ptr: &T) -> &T

Given ptr, which was obtained from a prior call to Self::borrow(), return a value with the same nominal lifetime which is guaranteed to survive mutations to Self. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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<T> DebugAny for T
where T: Any + Debug,

source§

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