[−][src]Struct snarkos_network::protocol::handshake::Handshake
Establishes a connection between this node and a peer to send messages.
- The server sends a Version message to a peer.
- The peer responds with a Verack message followed by a Version message.
- The server verifies the Verack and adds the peer to its peer list.
- The server sees the Version message and responds with a Verack.
- 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]
version: u64,
height: u32,
address_sender: SocketAddr,
address_receiver: SocketAddr
) -> Result<Self, HandshakeError>
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]
version: u64,
height: u32,
channel: Channel,
peer_message: Version,
local_address: SocketAddr,
peer_address: SocketAddr
) -> Result<Handshake, HandshakeError>
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]
&'_ mut self,
message: Version
) -> Result<(), HandshakeError>
Receive the Version message for an existing peer handshake. Send a Verack message.
pub async fn accept<'_>(
&'_ mut self,
message: Verack
) -> Result<(), HandshakeError>
[src]
&'_ mut self,
message: Verack
) -> Result<(), HandshakeError>
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
Auto Trait Implementations
impl !RefUnwindSafe for Handshake
impl Send for Handshake
impl Sync for Handshake
impl Unpin for Handshake
impl !UnwindSafe for Handshake
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,