async fn submit_transaction(
        &self,
        request: tonic::Request<SubmitTransactionRequest>,
    ) -> Result<tonic::Response<SubmitTransactionResponse>, tonic::Status> {
        trace!("[GRPC] AdmissionControl::submit_transaction");
        counters::REQUESTS
            .with_label_values(&["submit_transaction"])
            .inc();
        let txn_proto = request
            .into_inner()
            .transaction
            .unwrap_or_else(SignedTransactionProto::default);

        let txn = SignedTransaction::try_from(txn_proto).map_err(|e| {
            tonic::Status::new(
                tonic::Code::Internal,
                format!(
                    "[admission-control] Submitting transaction failed with error: {:?}",
                    e
                ),
            )
        })?;

        trace_code_block!("admission_control_service::submit_transaction", {"txn", txn.sender(), txn.sequence_number()});
        let (req_sender, res_receiver) = oneshot::channel();
        self.ac_sender
            .clone()
            .send((txn, req_sender))
            .await
            .map_err(|e| {
                tonic::Status::new(
                    tonic::Code::Internal,
                    format!(
                        "[admission-control] Failed to submit write request with error: {:?}",
                        e
                    ),
                )
            })?;

        let response = res_receiver
            .await
            .unwrap()
            .map(|(mempool_status, vm_status)| {
                let mut resp = SubmitTransactionResponse::default();
                if let Some(vm_error) = vm_status {
                    resp.status = Some(Status::VmStatus(VmStatusProto::from(vm_error)));
                } else if mempool_status.code == MempoolStatusCode::Accepted {
                    resp.status = Some(Status::AcStatus(AdmissionControlStatus::Accepted.into()));
                } else {
                    resp.status = Some(Status::MempoolStatus(MempoolStatusProto::from(
                        mempool_status,
                    )));
                }
                resp
            })
            .map_err(|e| {
                tonic::Status::new(
                    tonic::Code::Internal,
                    format!(
                        "[admission-control] Submitting transaction failed with error: {:?}",
                        e
                    ),
                )
            })?;
        Ok(tonic::Response::new(response))
    }
/// Submit a transaction to the validator this AC instance connecting to.
/// The specific transaction will be first validated by VM and then passed
/// to Mempool for further processing.
Submit a transaction to the validator this AC instance connecting to.
The specific transaction will be first validated by VM and then passed
to Mempool for further processing.
Submit a transaction to the validator this AC instance connecting to . The specific transaction will be first validated by VM and then passed to Mempool for further processing .
async fn submit_transaction(
        &self,
        request: tonic::Request<SubmitTransactionRequest>,
    ) -> Result<tonic::Response<SubmitTransactionResponse>, tonic::Status> {
        trace!("[GRPC] AdmissionControl::submit_transaction");
        counters::REQUESTS
            .with_label_values(&["submit_transaction"])
            .inc();
        let txn_proto = request
            .into_inner()
            .transaction
            .unwrap_or_else(SignedTransactionProto::default);
        let txn = SignedTransaction::try_from(txn_proto).map_err(|e| {
            tonic::Status::new(
                tonic::Code::Internal,
                format!(
                    "[admission-control] Submitting transaction failed with error: {:?}",
                    e
                ),
            )
        })?;
        trace_code_block!("admission_control_service::submit_transaction", {"txn", txn.sender(), txn.sequence_number()});
        let (req_sender, res_receiver) = oneshot::channel();
        self.ac_sender
            .clone()
            .send((txn, req_sender))
            .await
            .map_err(|e| {
                tonic::Status::new(
                    tonic::Code::Internal,
                    format!(
                        "[admission-control] Failed to submit write request with error: {:?}",
                        e
                    ),
                )
            })?;
        let response = res_receiver
            .await
            .unwrap()
            .map(|(mempool_status, vm_status)| {
                let mut resp = SubmitTransactionResponse::default();
                if let Some(vm_error) = vm_status {
                    resp.status = Some(Status::VmStatus(VmStatusProto::from(vm_error)));
                } else if mempool_status.code == MempoolStatusCode::Accepted {
                    resp.status = Some(Status::AcStatus(AdmissionControlStatus::Accepted.into()));
                } else {
                    resp.status = Some(Status::MempoolStatus(MempoolStatusProto::from(
                        mempool_status,
                    )));
                }
                resp
            })
            .map_err(|e| {
                tonic::Status::new(
                    tonic::Code::Internal,
                    format!(
                        "[admission-control] Submitting transaction failed with error: {:?}",
                        e
                    ),
                )
            })?;
        Ok(tonic::Response::new(response))
    }
async fn submit_transaction ( & self , request : tonic :: Request < SubmitTransactionRequest > , ) -> Result < tonic :: Response < SubmitTransactionResponse > , tonic :: Status > { trace ! ( " " ) ; counters :: REQUESTS . with_label_values ( & [ " " ] ) . inc ( ) ; let txn_proto = request . into_inner ( ) . transaction . unwrap_or_else ( SignedTransactionProto :: default ) ; let txn = SignedTransaction :: try_from ( txn_proto ) . map_err ( | e | { tonic :: Status :: new ( tonic :: Code :: Internal , format ! ( " " e ) , ) } ) ? ; trace_code_block ! ( " " { " " txn sender ( ) txn sequence_number ( ) } ) ; let ( req_sender , res_receiver ) = oneshot :: channel ( ) ; self . ac_sender . clone ( ) . send ( ( txn , req_sender ) ) . await . map_err ( | e | { tonic :: Status :: new ( tonic :: Code :: Internal , format ! ( " " e ) , ) } ) ? ; let response = res_receiver . await . unwrap ( ) . map ( | ( mempool_status , vm_status ) | { let mut resp = SubmitTransactionResponse :: default ( ) ; if let Some ( vm_error ) = vm_status { resp . status = Some ( Status :: VmStatus ( VmStatusProto :: from ( vm_error ) ) ) ; } else if mempool_status . code == MempoolStatusCode :: Accepted { resp . status = Some ( Status :: AcStatus ( AdmissionControlStatus :: Accepted . into ( ) ) ) ; } else { resp . status = Some ( Status :: MempoolStatus ( MempoolStatusProto :: from ( mempool_status , ) ) ) ; } resp } ) . map_err ( | e | { tonic :: Status :: new ( tonic :: Code :: Internal , format ! ( " " e ) , ) } ) ? ; Ok ( tonic :: Response :: new ( response ) ) }
Submit a transaction to the validator this AC instance connecting to.
Submit a transaction to the validator this AC instance connecting to .
&self
request
tonic::Request<SubmitTransactionRequest>
&self
request
tonic::Request<SubmitTransactionRequest>