[−][src]Struct snarkos_network::context::handshakes::Handshakes
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]
&'_ mut self,
version: u64,
height: u32,
address_sender: SocketAddr,
address_receiver: SocketAddr
) -> Result<(), HandshakeError>
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]
&'_ mut self,
version: u64,
height: u32,
local_address: SocketAddr,
peer_address: SocketAddr,
reader: TcpStream
) -> Result<(Handshake, SocketAddr), HandshakeError>
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]
&'_ mut self,
message: Version,
address_receiver: SocketAddr
) -> Result<(), HandshakeError>
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]
&'_ mut self,
address: SocketAddr,
message: Verack
) -> Result<(), HandshakeError>
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]
fn clone(&self) -> Handshakes
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for Handshakes
[src]
Auto Trait Implementations
impl !RefUnwindSafe for Handshakes
impl Send for Handshakes
impl Sync for Handshakes
impl Unpin for Handshakes
impl !UnwindSafe for Handshakes
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>,