[][src]Struct snarkos_network::context::handshakes::Handshakes

pub struct Handshakes { /* fields omitted */ }

Stores the address and latest state of peers we are handshaking with.

Implementations

impl Handshakes[src]

pub fn new() -> Self[src]

Construct a new store of connected peer Handshakes.

pub async fn send_request<'_>(
    &'_ mut self,
    version: u64,
    height: u32,
    address_sender: SocketAddr,
    address_receiver: SocketAddr
) -> Result<(), HandshakeError>
[src]

Create a new handshake with a peer and send a handshake request to them. If the request is sent successfully, the handshake is stored and returned.

pub async fn receive_any<'_>(
    &'_ mut self,
    version: u64,
    height: u32,
    local_address: SocketAddr,
    peer_address: SocketAddr,
    reader: TcpStream
) -> Result<(Handshake, SocketAddr), HandshakeError>
[src]

Receive the first message upon accepting a peer connection. If the message is a Version: 1. Create a new handshake. 2. Send a handshake response. 3. If the response is sent successfully, store the handshake. 4. Return the handshake and your address as seen by sender. If the message is a Verack: 1. Get the existing handshake. 2. Mark the handshake as accepted. 3. Send a request for peers. 4. Return the accepted handshake and your address as seen by sender.

pub async fn receive_request<'_>(
    &'_ mut self,
    message: Version,
    address_receiver: SocketAddr
) -> Result<(), HandshakeError>
[src]

Receive a handshake request from a connected peer. Update the handshake channel address if needed. Send a handshake response.

pub async fn accept_response<'_>(
    &'_ mut self,
    address: SocketAddr,
    message: Verack
) -> Result<(), HandshakeError>
[src]

Accept a handshake response from a connected peer.

pub fn get_state(&self, address: SocketAddr) -> Option<HandshakeState>[src]

Returns the state of the handshake at a peer address.

Trait Implementations

impl Clone for Handshakes[src]

impl Debug for Handshakes[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

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