async fn handle_request(
        &mut self,
        request: BaseNodeServiceRequest,
    ) -> Result<BaseNodeServiceResponse, BaseNodeServiceError> {
        debug!(
            target: LOG_TARGET,
            "Handling Wallet Base Node Service Request: {:?}", request
        );
        match request {
            BaseNodeServiceRequest::SetBaseNodePeer(peer) => {
                self.set_base_node_peer(*peer).await;
                Ok(BaseNodeServiceResponse::BaseNodePeerSet)
            },
            BaseNodeServiceRequest::GetBaseNodePeer => {
                let peer = self.get_state().await.base_node_peer.map(Box::new);
                Ok(BaseNodeServiceResponse::BaseNodePeer(peer))
            },
            BaseNodeServiceRequest::GetChainMetadata => match self.get_state().await.chain_metadata.clone() {
                Some(metadata) => Ok(BaseNodeServiceResponse::ChainMetadata(Some(metadata))),
                None => {
                    // if we don't have live state, check if we've previously stored state in the wallet db
                    let metadata = self.db.get_chain_metadata().await?;
                    Ok(BaseNodeServiceResponse::ChainMetadata(metadata))
                },
            },
            BaseNodeServiceRequest::GetBaseNodeLatency => {
                Ok(BaseNodeServiceResponse::Latency(self.state.read().await.latency))
            },
        }
    }
/// This handler is called when requests arrive from the various streams
This handler is called when requests arrive from the various streams
This handler is called when requests arrive from the various streams
async fn handle_request(
        &mut self,
        request: BaseNodeServiceRequest,
    ) -> Result<BaseNodeServiceResponse, BaseNodeServiceError> {
        debug!(
            target: LOG_TARGET,
            "Handling Wallet Base Node Service Request: {:?}", request
        );
        match request {
            BaseNodeServiceRequest::SetBaseNodePeer(peer) => {
                self.set_base_node_peer(*peer).await;
                Ok(BaseNodeServiceResponse::BaseNodePeerSet)
            },
            BaseNodeServiceRequest::GetBaseNodePeer => {
                let peer = self.get_state().await.base_node_peer.map(Box::new);
                Ok(BaseNodeServiceResponse::BaseNodePeer(peer))
            },
            BaseNodeServiceRequest::GetChainMetadata => match self.get_state().await.chain_metadata.clone() {
                Some(metadata) => Ok(BaseNodeServiceResponse::ChainMetadata(Some(metadata))),
                None => {
                    // if we don't have live state, check if we've previously stored state in the wallet db
                    let metadata = self.db.get_chain_metadata().await?;
                    Ok(BaseNodeServiceResponse::ChainMetadata(metadata))
                },
            },
            BaseNodeServiceRequest::GetBaseNodeLatency => {
                Ok(BaseNodeServiceResponse::Latency(self.state.read().await.latency))
            },
        }
    }
async fn handle_request ( & mut self , request : BaseNodeServiceRequest , ) -> Result < BaseNodeServiceResponse , BaseNodeServiceError > { debug ! ( target LOG_TARGET " " request ) ; match request { BaseNodeServiceRequest :: SetBaseNodePeer ( peer ) => { self . set_base_node_peer ( * peer ) . await ; Ok ( BaseNodeServiceResponse :: BaseNodePeerSet ) } , BaseNodeServiceRequest :: GetBaseNodePeer => { let peer = self . get_state ( ) . await . base_node_peer . map ( Box :: new ) ; Ok ( BaseNodeServiceResponse :: BaseNodePeer ( peer ) ) } , BaseNodeServiceRequest :: GetChainMetadata => match self . get_state ( ) . await . chain_metadata . clone ( ) { Some ( metadata ) => Ok ( BaseNodeServiceResponse :: ChainMetadata ( Some ( metadata ) ) ) , None => { // if we don't have live state, check if we've previously stored state in the wallet db let metadata = self . db . get_chain_metadata ( ) . await ? ; Ok ( BaseNodeServiceResponse :: ChainMetadata ( metadata ) ) } , } , BaseNodeServiceRequest :: GetBaseNodeLatency => { Ok ( BaseNodeServiceResponse :: Latency ( self . state . read ( ) . await . latency ) ) } , } }
This handler is called when requests arrive from the various streams
This handler is called when requests arrive from the various streams
&mut self
request
BaseNodeServiceRequest
&mut self
request
BaseNodeServiceRequest