Struct stack_epic_p2p::Peer
source · pub struct Peer {
pub info: PeerInfo,
/* private fields */
}Fields§
§info: PeerInfoImplementations§
source§impl Peer
impl Peer
pub fn accept( conn: TcpStream, capab: Capabilities, total_difficulty: Difficulty, hs: &Handshake, adapter: Arc<dyn NetAdapter> ) -> Result<Peer, Error>
pub fn connect( conn: TcpStream, capab: Capabilities, total_difficulty: Difficulty, self_addr: PeerAddr, hs: &Handshake, adapter: Arc<dyn NetAdapter> ) -> Result<Peer, Error>
pub fn is_denied(config: &P2PConfig, peer_addr: PeerAddr) -> bool
sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Whether this peer is currently connected.
sourcepub fn is_stuck(&self) -> (bool, Difficulty)
pub fn is_stuck(&self) -> (bool, Difficulty)
Whether this peer is stuck on sync.
sourcepub fn is_abusive(&self) -> bool
pub fn is_abusive(&self) -> bool
Whether the peer is considered abusive, mostly for spammy nodes
sourcepub fn last_min_sent_bytes(&self) -> Option<u64>
pub fn last_min_sent_bytes(&self) -> Option<u64>
Number of bytes sent to the peer
sourcepub fn last_min_received_bytes(&self) -> Option<u64>
pub fn last_min_received_bytes(&self) -> Option<u64>
Number of bytes received from the peer
pub fn last_min_message_counts(&self) -> Option<(u64, u64)>
sourcepub fn set_banned(&self)
pub fn set_banned(&self)
Set this peer status to banned
sourcepub fn send_ping(
&self,
total_difficulty: Difficulty,
height: u64,
local_timestamp: i64
) -> Result<(), Error>
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
sourcepub fn send_ban_reason(&self, ban_reason: ReasonForBan) -> Result<(), Error>
pub fn send_ban_reason(&self, ban_reason: ReasonForBan) -> Result<(), Error>
Send the ban reason before banning
sourcepub fn send_block(&self, b: &Block) -> Result<bool, Error>
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.
pub fn send_compact_block(&self, b: &CompactBlock) -> Result<bool, Error>
pub fn send_header(&self, bh: &BlockHeader) -> Result<bool, Error>
pub fn send_tx_kernel_hash(&self, h: Hash) -> Result<bool, Error>
sourcepub fn send_transaction(&self, tx: &Transaction) -> Result<bool, Error>
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.
sourcepub fn send_stem_transaction(&self, tx: &Transaction) -> Result<(), Error>
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).
sourcepub fn send_header_request(&self, locator: Vec<Hash>) -> Result<(), Error>
pub fn send_header_request(&self, locator: Vec<Hash>) -> Result<(), Error>
Sends a request for block headers from the provided block locator
sourcepub fn send_header_fastsync_request(
&self,
locator: Vec<Hash>,
offset: u8
) -> Result<(), Error>
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
pub fn send_tx_request(&self, h: Hash) -> Result<(), Error>
sourcepub fn send_block_request(&self, h: Hash, opts: Options) -> Result<(), Error>
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.
sourcepub fn send_compact_block_request(&self, h: Hash) -> Result<(), Error>
pub fn send_compact_block_request(&self, h: Hash) -> Result<(), Error>
Sends a request for a specific compact block by hash
pub fn send_peer_request(&self, capab: Capabilities) -> Result<(), Error>
pub fn send_txhashset_request( &self, height: u64, hash: Hash ) -> Result<(), Error>
pub fn send_kernel_data_request(&self) -> Result<(), Error>
Trait Implementations§
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> 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
§impl<T> SafeBorrow<T> for Twhere
T: ?Sized,
impl<T> SafeBorrow<T> for Twhere
T: ?Sized,
§fn borrow_replacement(ptr: &T) -> &T
fn borrow_replacement(ptr: &T) -> &T
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