Struct Peer

Source
pub struct Peer {
Show 18 fields pub index: PeerIndex, pub peer_status: PeerStatus, pub block_fetch_url: String, pub static_peer_config: Option<PeerConfig>, pub challenge_for_peer: Option<SaitoHash>, pub key_list: Vec<SaitoPublicKey>, pub services: Vec<PeerService>, pub last_msg_at: Timestamp, pub disconnected_at: Timestamp, pub wallet_version: Version, pub core_version: Version, pub key_list_limiter: RateLimiter, pub handshake_limiter: RateLimiter, pub message_limiter: RateLimiter, pub invalid_block_limiter: RateLimiter, pub public_key: Option<SaitoPublicKey>, pub peer_type: PeerType, pub ip_address: Option<String>,
}

Fields§

§index: PeerIndex§peer_status: PeerStatus§block_fetch_url: String§static_peer_config: Option<PeerConfig>§challenge_for_peer: Option<SaitoHash>§key_list: Vec<SaitoPublicKey>§services: Vec<PeerService>§last_msg_at: Timestamp§disconnected_at: Timestamp§wallet_version: Version§core_version: Version§key_list_limiter: RateLimiter§handshake_limiter: RateLimiter§message_limiter: RateLimiter§invalid_block_limiter: RateLimiter§public_key: Option<SaitoPublicKey>§peer_type: PeerType§ip_address: Option<String>

Implementations§

Source§

impl Peer

Source

pub fn new(peer_index: PeerIndex) -> Peer

Source

pub fn new_stun( peer_index: PeerIndex, public_key: SaitoPublicKey, io_handler: &(dyn InterfaceIO + Send + Sync), ) -> Peer

Source

pub fn is_stun_peer(&self) -> bool

Source

pub fn has_key_list_limit_exceeded(&mut self, current_time: Timestamp) -> bool

Source

pub fn has_handshake_limit_exceeded(&mut self, current_time: Timestamp) -> bool

Source

pub fn has_message_limit_exceeded(&mut self, current_time: Timestamp) -> bool

Source

pub fn has_invalid_block_limit_exceeded( &mut self, current_time: Timestamp, ) -> bool

Source

pub fn get_limited_till(&mut self, current_time: Timestamp) -> Option<Timestamp>

Source

pub fn get_url(&self) -> String

Source

pub async fn initiate_handshake( &mut self, io_handler: &(dyn InterfaceIO + Send + Sync), ) -> Result<(), Error>

Source

pub async fn handle_handshake_challenge( &mut self, challenge: HandshakeChallenge, io_handler: &(dyn InterfaceIO + Send + Sync), wallet_lock: Arc<RwLock<Wallet>>, configs_lock: Arc<RwLock<dyn Configuration + Send + Sync>>, ) -> Result<(), Error>

Source

pub async fn handle_handshake_response( &mut self, response: HandshakeResponse, io_handler: &(dyn InterfaceIO + Send + Sync), wallet_lock: Arc<RwLock<Wallet>>, configs_lock: Arc<RwLock<dyn Configuration + Send + Sync>>, current_time: Timestamp, ) -> Result<(), Error>

Source

pub fn get_block_fetch_url( &self, block_hash: SaitoHash, lite: bool, my_public_key: SaitoPublicKey, ) -> String

Since each peer have a different url for a block to be fetched, this function will generate the correct url from a given block hash

§Arguments
  • block_hash: hash of the block to be fetched

returns: String

§Examples
Source

pub async fn send_ping( &mut self, current_time: Timestamp, io_handler: &(dyn InterfaceIO + Send + Sync), )

Source

pub fn has_service(&self, service: String) -> bool

Source

pub fn compare_version(&self, version: &Version) -> Option<Ordering>

Source

pub fn is_static_peer(&self) -> bool

Source

pub fn get_public_key(&self) -> Option<SaitoPublicKey>

Source

pub fn mark_as_disconnected(&mut self, disconnected_at: Timestamp)

Trait Implementations§

Source§

impl Clone for Peer

Source§

fn clone(&self) -> Peer

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 Peer

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Peer

§

impl RefUnwindSafe for Peer

§

impl Send for Peer

§

impl Sync for Peer

§

impl Unpin for Peer

§

impl UnwindSafe for Peer

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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

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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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