/// Process Request items sent by clients.
Process Request items sent by clients.
Process Request items sent by clients .
pub fn process_request(
        &self,
        msg: Request,
        rsp_addr: SocketAddr,
    ) -> Option<(Response, SocketAddr)> {
        match msg {
            Request::GetBalance { key } => {
                let val = self.acc.lock().unwrap().get_balance(&key);
                let rsp = (Response::Balance { key, val }, rsp_addr);
                info!("Response::Balance {:?}", rsp);
                Some(rsp)
            }
            Request::Transaction(_) => unreachable!(),
            Request::Subscribe { subscriptions } => {
                for subscription in subscriptions {
                    match subscription {
                        Subscription::EntryInfo => {
                            self.entry_info_subscribers.lock().unwrap().push(rsp_addr)
                        }
                    }
                }
                None
            }
        }
    }
pub fn process_request ( & self , msg : Request , rsp_addr : SocketAddr , ) -> Option < ( Response , SocketAddr ) > { match msg { Request :: GetBalance { key } => { let val = self . acc . lock ( ) . unwrap ( ) . get_balance ( & key ) ; let rsp = ( Response :: Balance { key , val } , rsp_addr ) ; info ! ( " " rsp ) ; Some ( rsp ) } Request :: Transaction ( _ ) => unreachable ! ( ) , Request :: Subscribe { subscriptions } => { for subscription in subscriptions { match subscription { Subscription :: EntryInfo => { self . entry_info_subscribers . lock ( ) . unwrap ( ) . push ( rsp_addr ) } } } None } } }
Process Request items sent by clients.
Process Request items sent by clients .
&self
msg
Request
rsp_addr
SocketAddr