/// Sends a request to the connected base node to retrieve chain metadata.
Sends a request to the connected base node to retrieve chain metadata.
Sends a request to the connected base node to retrieve chain metadata .
async fn refresh_chain_metadata(&mut self) -> Result<(), BaseNodeServiceError> {
        debug!(target: LOG_TARGET, "Refresh chain metadata");
        let dest_public_key = self
            .base_node_public_key
            .clone()
            .ok_or_else(|| BaseNodeServiceError::NoBaseNodePublicKey)?;
        let request_key = generate_request_key(&mut OsRng);
        let now = Utc::now().naive_utc();
        self.requests.push(RequestMetadata { request_key, sent: now });
        // remove old request keys
        let (current_requests, old): (Vec<RequestMetadata>, Vec<RequestMetadata>) =
            self.requests.iter().partition(|r| {
                let age = Utc::now().naive_utc() - r.sent;
                // convert to std Duration
                let age = Duration::from_millis(age.num_milliseconds() as u64);
                age <= self.config.request_keys_max_age
            });
        trace!(target: LOG_TARGET, "current requests: {:?}", current_requests);
        trace!(target: LOG_TARGET, "discarded requests : {:?}", old);
        self.requests = current_requests;
        let request = BaseNodeRequestProto::GetChainMetadata(true);
        let service_request = BaseNodeProto::BaseNodeServiceRequest {
            request_key,
            request: Some(request),
        };
        let message = OutboundDomainMessage::new(TariMessageType::BaseNodeRequest, service_request);
        self.outbound_messaging
            .send_direct(dest_public_key, message)
            .await
            .map_err(BaseNodeServiceError::OutboundError)?;
        debug!(target: LOG_TARGET, "Refresh chain metadata sent");
        Ok(())
    }
async fn refresh_chain_metadata ( & mut self ) -> Result < ( ) , BaseNodeServiceError > { debug ! ( target LOG_TARGET " " ) ; let dest_public_key = self . base_node_public_key . clone ( ) . ok_or_else ( | | BaseNodeServiceError :: NoBaseNodePublicKey ) ? ; let request_key = generate_request_key ( & mut OsRng ) ; let now = Utc :: now ( ) . naive_utc ( ) ; self . requests . push ( RequestMetadata { request_key , sent : now } ) ; // remove old request keys let ( current_requests , old ) : ( Vec < RequestMetadata > , Vec < RequestMetadata > ) = self . requests . iter ( ) . partition ( | r | { let age = Utc :: now ( ) . naive_utc ( ) - r . sent ; // convert to std Duration let age = Duration :: from_millis ( age . num_milliseconds ( ) as u64 ) ; age <= self . config . request_keys_max_age } ) ; trace ! ( target LOG_TARGET " " current_requests ) ; trace ! ( target LOG_TARGET " " old ) ; self . requests = current_requests ; let request = BaseNodeRequestProto :: GetChainMetadata ( true ) ; let service_request = BaseNodeProto :: BaseNodeServiceRequest { request_key , request : Some ( request ) , } ; let message = OutboundDomainMessage :: new ( TariMessageType :: BaseNodeRequest , service_request ) ; self . outbound_messaging . send_direct ( dest_public_key , message ) . await . map_err ( BaseNodeServiceError :: OutboundError ) ? ; debug ! ( target LOG_TARGET " " ) ; Ok ( ( ) ) }
Sends a request to the connected base node to retrieve chain metadata.
Sends a request to the connected base node to retrieve chain metadata .
&mut self