[][src]Struct snarkos_network::protocol::handshake::Handshake

pub struct Handshake {
    pub channel: Arc<Channel>,
    // some fields omitted
}

Establishes a connection between this node and a peer to send messages.

  1. The server sends a Version message to a peer.
  2. The peer responds with a Verack message followed by a Version message.
  3. The server verifies the Verack and adds the peer to its peer list.
  4. The server sees the Version message and responds with a Verack.
  5. The peer verifies the Verack and adds the server to its peer list.

Receiving a Version message means you should send a Verack message. If you receive a Verack message from a peer and accept it, then the handshake is complete. Peers with completed handshakes are added to your connections and your connected peer list.

Fields

channel: Arc<Channel>

Implementations

impl Handshake[src]

pub async fn send_new(
    version: u64,
    height: u32,
    address_sender: SocketAddr,
    address_receiver: SocketAddr
) -> Result<Self, HandshakeError>
[src]

Send the initial Version message to a peer

pub async fn receive_new(
    version: u64,
    height: u32,
    channel: Channel,
    peer_message: Version,
    local_address: SocketAddr,
    peer_address: SocketAddr
) -> Result<Handshake, HandshakeError>
[src]

Receive the initial Version message from a new peer. Send a Verack message + Version message

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

Receive the Version message for an existing peer handshake. Send a Verack message.

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

Accept the Verack from a peer.

pub fn update_address(&mut self, address: SocketAddr)[src]

Updates the stored channel address if needed for an existing peer handshake.

pub fn update_reader(&mut self, read_channel: Channel)[src]

Updates the stored reader stream for an existing peer handshake.

pub fn get_state(&self) -> HandshakeState[src]

Returns current handshake state.

Trait Implementations

impl Clone for Handshake[src]

impl Debug for Handshake[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>,