Struct stack_epic_p2p::Peer

source ·
pub struct Peer {
    pub info: PeerInfo,
    /* private fields */
}

Fields§

§info: PeerInfo

Implementations§

source§

impl Peer

source

pub fn accept( conn: TcpStream, capab: Capabilities, total_difficulty: Difficulty, hs: &Handshake, adapter: Arc<dyn NetAdapter> ) -> Result<Peer, Error>

source

pub fn connect( conn: TcpStream, capab: Capabilities, total_difficulty: Difficulty, self_addr: PeerAddr, hs: &Handshake, adapter: Arc<dyn NetAdapter> ) -> Result<Peer, Error>

source

pub fn is_denied(config: &P2PConfig, peer_addr: PeerAddr) -> bool

source

pub fn is_connected(&self) -> bool

Whether this peer is currently connected.

source

pub fn is_banned(&self) -> bool

Whether this peer has been banned.

source

pub fn is_stuck(&self) -> (bool, Difficulty)

Whether this peer is stuck on sync.

source

pub fn is_abusive(&self) -> bool

Whether the peer is considered abusive, mostly for spammy nodes

source

pub fn last_min_sent_bytes(&self) -> Option<u64>

Number of bytes sent to the peer

source

pub fn last_min_received_bytes(&self) -> Option<u64>

Number of bytes received from the peer

source

pub fn last_min_message_counts(&self) -> Option<(u64, u64)>

source

pub fn set_banned(&self)

Set this peer status to banned

source

pub fn send_ping( &self, total_difficulty: Difficulty, height: u64, local_timestamp: i64 ) -> Result<(), Error>

Send a ping to the remote peer, providing our local difficulty and height

source

pub fn send_ban_reason(&self, ban_reason: ReasonForBan) -> Result<(), Error>

Send the ban reason before banning

source

pub fn send_block(&self, b: &Block) -> Result<bool, Error>

Sends the provided block to the remote peer. The request may be dropped if the remote peer is known to already have the block.

source

pub fn send_compact_block(&self, b: &CompactBlock) -> Result<bool, Error>

source

pub fn send_header(&self, bh: &BlockHeader) -> Result<bool, Error>

source

pub fn send_tx_kernel_hash(&self, h: Hash) -> Result<bool, Error>

source

pub fn send_transaction(&self, tx: &Transaction) -> Result<bool, Error>

Sends the provided transaction to the remote peer. The request may be dropped if the remote peer is known to already have the transaction. We support broadcast of lightweight tx kernel hash so track known txs by kernel hash.

source

pub fn send_stem_transaction(&self, tx: &Transaction) -> Result<(), Error>

Sends the provided stem transaction to the remote peer. Note: tracking adapter is ignored for stem transactions (while under embargo).

source

pub fn send_header_request(&self, locator: Vec<Hash>) -> Result<(), Error>

Sends a request for block headers from the provided block locator

source

pub fn send_header_fastsync_request( &self, locator: Vec<Hash>, offset: u8 ) -> Result<(), Error>

Sends a request for block headers with a offset value from the provided block locator

source

pub fn send_tx_request(&self, h: Hash) -> Result<(), Error>

source

pub fn send_block_request(&self, h: Hash, opts: Options) -> Result<(), Error>

Sends a request for a specific block by hash. Takes opts so we can track if this request was due to our node syncing or otherwise.

source

pub fn send_compact_block_request(&self, h: Hash) -> Result<(), Error>

Sends a request for a specific compact block by hash

source

pub fn send_peer_request(&self, capab: Capabilities) -> Result<(), Error>

source

pub fn send_txhashset_request( &self, height: u64, hash: Hash ) -> Result<(), Error>

source

pub fn send_kernel_data_request(&self) -> Result<(), Error>

source

pub fn stop(&self)

Stops the peer

source

pub fn wait(&self)

Waits until the peer’s thread exit

Trait Implementations§

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

§

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

§

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

impl<T> DebugAny for T
where T: Any + Debug,

§

impl<T> Erased for T

§

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