Struct Peer

Source
pub struct Peer<T: AsyncWrite + Unpin + Send + Sync> {
Show 26 fields mempool: Arc<Mutex<Mempool>>, blocks_only: bool, services: ServiceFlags, user_agent: String, messages: u64, start_time: Instant, last_message: Instant, last_addrv2: Instant, last_inv: Instant, current_best_block: i32, last_ping: Option<Instant>, id: u32, node_tx: UnboundedSender<NodeNotification>, state: State, send_headers: bool, node_requests: UnboundedReceiver<NodeRequest>, address: LocalAddress, kind: ConnectionKind, wants_addrv2: bool, shutdown: bool, actor_receiver: UnboundedReceiver<ReaderMessage>, writer: WriteTransport<T>, our_user_agent: String, our_best_block: u32, cancellation_sender: Option<Sender<()>>, transport_protocol: TransportProtocol,
}

Fields§

§mempool: Arc<Mutex<Mempool>>§blocks_only: bool§services: ServiceFlags§user_agent: String§messages: u64§start_time: Instant§last_message: Instant§last_addrv2: Instant§last_inv: Instant§current_best_block: i32§last_ping: Option<Instant>§id: u32§node_tx: UnboundedSender<NodeNotification>§state: State§send_headers: bool§node_requests: UnboundedReceiver<NodeRequest>§address: LocalAddress§kind: ConnectionKind§wants_addrv2: bool§shutdown: bool§actor_receiver: UnboundedReceiver<ReaderMessage>§writer: WriteTransport<T>§our_user_agent: String§our_best_block: u32§cancellation_sender: Option<Sender<()>>§transport_protocol: TransportProtocol

Implementations§

Source§

impl<T: AsyncWrite + Unpin + Send + Sync> Peer<T>

Source

pub async fn read_loop(self) -> Result<Self, PeerError>

Source

async fn peer_loop_inner(&mut self) -> Result<(), PeerError>

Source

pub async fn handle_node_request( &mut self, request: NodeRequest, ) -> Result<(), PeerError>

Source

pub async fn handle_peer_message( &mut self, message: NetworkMessage, time: Instant, ) -> Result<(), PeerError>

Source§

impl<T: AsyncWrite + Unpin + Send + Sync> Peer<T>

Source

pub async fn write(&mut self, msg: NetworkMessage) -> Result<(), PeerError>

Source

pub async fn handle_get_data(&mut self, inv: Inventory) -> Result<(), PeerError>

Source

pub fn create_peer<W: AsyncWrite + Unpin + Send + Sync + 'static>( id: u32, address: LocalAddress, mempool: Arc<Mutex<Mempool>>, node_tx: UnboundedSender<NodeNotification>, node_requests: UnboundedReceiver<NodeRequest>, kind: ConnectionKind, actor_receiver: UnboundedReceiver<ReaderMessage>, writer: WriteTransport<W>, our_user_agent: String, our_best_block: u32, cancellation_sender: Sender<()>, transport_protocol: TransportProtocol, )

Source

async fn handle_ping(&mut self, nonce: u64) -> Result<(), PeerError>

Source

async fn handle_version( &mut self, version: VersionMessage, ) -> Result<(), PeerError>

Source

fn send_to_node(&self, message: PeerMessages, time: Instant)

Trait Implementations§

Source§

impl<T: AsyncWrite + Unpin + Send + Sync> Debug for Peer<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Peer<T>
where T: Freeze,

§

impl<T> !RefUnwindSafe for Peer<T>

§

impl<T> Send for Peer<T>

§

impl<T> Sync for Peer<T>

§

impl<T> Unpin for Peer<T>

§

impl<T> !UnwindSafe for Peer<T>

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.

§

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.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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