Struct saito_rust::peer::SaitoPeer [−][src]
pub struct SaitoPeer { /* fields omitted */ }
Expand description
A Peer. i.e. another node in the network.
Implementations
pub fn new(
connection_id: SaitoHash,
host: Option<[u8; 4]>,
port: Option<u16>,
is_connected_or_connecting: bool,
has_completed_handshake: bool,
is_from_peer_list: bool,
wallet_lock: Arc<RwLock<Wallet>>,
mempool_lock: Arc<RwLock<Mempool>>,
blockchain_lock: Arc<RwLock<Blockchain>>,
broadcast_channel_sender: Sender<SaitoMessage>
) -> SaitoPeer
this setter also will reset the appropriate flags on the peer if the peer becomes disconnected. Once disconnected, we want to also redo the handshake because this will help avoid IP-based connection stealing.
pub fn send_command<'life0, 'life_self, 'async_recursion>(
&'life_self mut self,
command: &'life0 str,
message: Vec<u8>
) -> Pin<Box<dyn Future<Output = Result<APIMessage, APIMessage>> + Send + 'async_recursion>> where
'life0: 'async_recursion,
'life_self: 'async_recursion,
pub fn send_command<'life0, 'life_self, 'async_recursion>(
&'life_self mut self,
command: &'life0 str,
message: Vec<u8>
) -> Pin<Box<dyn Future<Output = Result<APIMessage, APIMessage>> + Send + 'async_recursion>> where
'life0: 'async_recursion,
'life_self: 'async_recursion,
This creates a PeerRequest Future(which sends the APIMessage to the peer), await’s the response, and wraps the returned message into a Result(RESULT__ => Ok(), ERROR___ => Err()).
sends a command to the peer’s socket but doesn’t not await the response
Helper function for sending basic OK results.
Helper function for sending RESULT__.
Helper function for sending basic errors with a string message.
Helper function for sending errors
handle any APIMessage from the socket. RESULT/ERROR will be matched to it’s COMMAND via the ID and the Future will be polled via it’s waker. Normal commands will be handled by handle_peer_command.
Auto Trait Implementations
impl !RefUnwindSafe for SaitoPeer
impl !UnwindSafe for SaitoPeer
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more