// This file is @generated by prost-build.
/// Represents the status of the block producer.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct BlockProducerStatus {
    /// The block producer's running version.
    #[prost(string, tag = "1")]
    pub version: ::prost::alloc::string::String,
    /// The block producer's status.
    #[prost(string, tag = "2")]
    pub status: ::prost::alloc::string::String,
}
/// Represents the result of submitting proven transaction.
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct SubmitProvenTransactionResponse {
    /// The node's current block height.
    #[prost(fixed32, tag = "1")]
    pub block_height: u32,
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct SubmitProvenBatchResponse {
    /// The node's current block height.
    #[prost(fixed32, tag = "1")]
    pub block_height: u32,
}
/// Request to subscribe to mempool events.
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct MempoolSubscriptionRequest {
    /// The caller's current chain height.
    ///
    /// Request will be rejected if this does not match the mempool's current view.
    #[prost(fixed32, tag = "1")]
    pub chain_tip: u32,
}
/// Event from the mempool.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MempoolEvent {
    #[prost(oneof = "mempool_event::Event", tags = "1, 2, 3")]
    pub event: ::core::option::Option<mempool_event::Event>,
}
/// Nested message and enum types in `MempoolEvent`.
pub mod mempool_event {
    /// A block was committed.
    ///
    /// This event is sent when a block is committed to the chain.
    #[derive(Clone, PartialEq, ::prost::Message)]
    pub struct BlockCommitted {
        #[prost(message, optional, tag = "1")]
        pub block_header: ::core::option::Option<super::super::blockchain::BlockHeader>,
        #[prost(message, repeated, tag = "2")]
        pub transactions: ::prost::alloc::vec::Vec<
            super::super::transaction::TransactionId,
        >,
    }
    /// A transaction was added to the mempool.
    ///
    /// This event is sent when a transaction is added to the mempool.
    #[derive(Clone, PartialEq, ::prost::Message)]
    pub struct TransactionAdded {
        /// The ID of the transaction.
        #[prost(message, optional, tag = "1")]
        pub id: ::core::option::Option<super::super::transaction::TransactionId>,
        /// Nullifiers consumed by the transaction.
        #[prost(message, repeated, tag = "2")]
        pub nullifiers: ::prost::alloc::vec::Vec<super::super::primitives::Digest>,
        /// Network notes created by the transaction.
        #[prost(message, repeated, tag = "3")]
        pub network_notes: ::prost::alloc::vec::Vec<super::super::note::NetworkNote>,
        /// Changes to a network account, if any. This includes creation of new network accounts.
        ///
        /// The account delta is encoded using \[winter_utils::Serializable\] implementation
        /// for \[miden_objects::account::delta::AccountDelta\].
        #[prost(bytes = "vec", optional, tag = "4")]
        pub network_account_delta: ::core::option::Option<::prost::alloc::vec::Vec<u8>>,
    }
    /// A set of transactions was reverted and dropped from the mempool.
    ///
    /// This event is sent when a set of transactions are reverted and dropped from the mempool.
    #[derive(Clone, PartialEq, ::prost::Message)]
    pub struct TransactionsReverted {
        #[prost(message, repeated, tag = "1")]
        pub reverted: ::prost::alloc::vec::Vec<super::super::transaction::TransactionId>,
    }
    #[derive(Clone, PartialEq, ::prost::Oneof)]
    pub enum Event {
        #[prost(message, tag = "1")]
        TransactionAdded(TransactionAdded),
        #[prost(message, tag = "2")]
        BlockCommitted(BlockCommitted),
        #[prost(message, tag = "3")]
        TransactionsReverted(TransactionsReverted),
    }
}
/// Generated client implementations.
pub mod api_client {
    #![allow(
        unused_variables,
        dead_code,
        missing_docs,
        clippy::wildcard_imports,
        clippy::let_unit_value,
    )]
    use tonic::codegen::*;
    use tonic::codegen::http::Uri;
    #[derive(Debug, Clone)]
    pub struct ApiClient<T> {
        inner: tonic::client::Grpc<T>,
    }
    impl ApiClient<tonic::transport::Channel> {
        /// Attempt to create a new client by connecting to a given endpoint.
        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
        where
            D: TryInto<tonic::transport::Endpoint>,
            D::Error: Into<StdError>,
        {
            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
            Ok(Self::new(conn))
        }
    }
    impl<T> ApiClient<T>
    where
        T: tonic::client::GrpcService<tonic::body::Body>,
        T::Error: Into<StdError>,
        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
    {
        pub fn new(inner: T) -> Self {
            let inner = tonic::client::Grpc::new(inner);
            Self { inner }
        }
        pub fn with_origin(inner: T, origin: Uri) -> Self {
            let inner = tonic::client::Grpc::with_origin(inner, origin);
            Self { inner }
        }
        pub fn with_interceptor<F>(
            inner: T,
            interceptor: F,
        ) -> ApiClient<InterceptedService<T, F>>
        where
            F: tonic::service::Interceptor,
            T::ResponseBody: Default,
            T: tonic::codegen::Service<
                http::Request<tonic::body::Body>,
                Response = http::Response<
                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
                >,
            >,
            <T as tonic::codegen::Service<
                http::Request<tonic::body::Body>,
            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
        {
            ApiClient::new(InterceptedService::new(inner, interceptor))
        }
        /// Compress requests with the given encoding.
        ///
        /// This requires the server to support it otherwise it might respond with an
        /// error.
        #[must_use]
        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.send_compressed(encoding);
            self
        }
        /// Enable decompressing responses.
        #[must_use]
        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.accept_compressed(encoding);
            self
        }
        /// Limits the maximum size of a decoded message.
        ///
        /// Default: `4MB`
        #[must_use]
        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_decoding_message_size(limit);
            self
        }
        /// Limits the maximum size of an encoded message.
        ///
        /// Default: `usize::MAX`
        #[must_use]
        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_encoding_message_size(limit);
            self
        }
        /// Returns the status info.
        pub async fn status(
            &mut self,
            request: impl tonic::IntoRequest<()>,
        ) -> std::result::Result<
            tonic::Response<super::BlockProducerStatus>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/block_producer.Api/Status",
            );
            let mut req = request.into_request();
            req.extensions_mut().insert(GrpcMethod::new("block_producer.Api", "Status"));
            self.inner.unary(req, path, codec).await
        }
        /// Submits proven transaction to the Miden network
        pub async fn submit_proven_transaction(
            &mut self,
            request: impl tonic::IntoRequest<
                super::super::transaction::ProvenTransaction,
            >,
        ) -> std::result::Result<
            tonic::Response<super::SubmitProvenTransactionResponse>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/block_producer.Api/SubmitProvenTransaction",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new("block_producer.Api", "SubmitProvenTransaction"),
                );
            self.inner.unary(req, path, codec).await
        }
        /// Submits a proven batch to the Miden network.
        ///
        /// The batch may include transactions which were are:
        ///
        /// * already in the mempool i.e. previously successfully submitted
        /// * will be submitted to the mempool in the future
        /// * won't be submitted to the mempool at all
        ///
        /// All transactions in the batch but not in the mempool must build on the current mempool
        /// state following normal transaction submission rules.
        pub async fn submit_proven_batch(
            &mut self,
            request: impl tonic::IntoRequest<
                super::super::transaction::ProvenTransactionBatch,
            >,
        ) -> std::result::Result<
            tonic::Response<super::SubmitProvenBatchResponse>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/block_producer.Api/SubmitProvenBatch",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(GrpcMethod::new("block_producer.Api", "SubmitProvenBatch"));
            self.inner.unary(req, path, codec).await
        }
        /// Subscribe to mempool events.
        ///
        /// The request will be rejected if the caller and the mempool disagree on the current chain tip.
        /// This prevents potential desync issues. The caller can resolve this by resync'ing its chain state.
        ///
        /// The event stream will contain all events after the chain tip. This includes all currently inflight
        /// events that have not yet been committed to the chain.
        ///
        /// Currently only a single active subscription is supported. Subscription requests will cancel the active
        /// subscription, if any.
        pub async fn mempool_subscription(
            &mut self,
            request: impl tonic::IntoRequest<super::MempoolSubscriptionRequest>,
        ) -> std::result::Result<
            tonic::Response<tonic::codec::Streaming<super::MempoolEvent>>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/block_producer.Api/MempoolSubscription",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(GrpcMethod::new("block_producer.Api", "MempoolSubscription"));
            self.inner.server_streaming(req, path, codec).await
        }
    }
}
/// Generated server implementations.
pub mod api_server {
    #![allow(
        unused_variables,
        dead_code,
        missing_docs,
        clippy::wildcard_imports,
        clippy::let_unit_value,
    )]
    use tonic::codegen::*;
    /// Generated trait containing gRPC methods that should be implemented for use with ApiServer.
    #[async_trait]
    pub trait Api: std::marker::Send + std::marker::Sync + 'static {
        /// Returns the status info.
        async fn status(
            &self,
            request: tonic::Request<()>,
        ) -> std::result::Result<
            tonic::Response<super::BlockProducerStatus>,
            tonic::Status,
        >;
        /// Submits proven transaction to the Miden network
        async fn submit_proven_transaction(
            &self,
            request: tonic::Request<super::super::transaction::ProvenTransaction>,
        ) -> std::result::Result<
            tonic::Response<super::SubmitProvenTransactionResponse>,
            tonic::Status,
        >;
        /// Submits a proven batch to the Miden network.
        ///
        /// The batch may include transactions which were are:
        ///
        /// * already in the mempool i.e. previously successfully submitted
        /// * will be submitted to the mempool in the future
        /// * won't be submitted to the mempool at all
        ///
        /// All transactions in the batch but not in the mempool must build on the current mempool
        /// state following normal transaction submission rules.
        async fn submit_proven_batch(
            &self,
            request: tonic::Request<super::super::transaction::ProvenTransactionBatch>,
        ) -> std::result::Result<
            tonic::Response<super::SubmitProvenBatchResponse>,
            tonic::Status,
        >;
        /// Server streaming response type for the MempoolSubscription method.
        type MempoolSubscriptionStream: tonic::codegen::tokio_stream::Stream<
                Item = std::result::Result<super::MempoolEvent, tonic::Status>,
            >
            + std::marker::Send
            + 'static;
        /// Subscribe to mempool events.
        ///
        /// The request will be rejected if the caller and the mempool disagree on the current chain tip.
        /// This prevents potential desync issues. The caller can resolve this by resync'ing its chain state.
        ///
        /// The event stream will contain all events after the chain tip. This includes all currently inflight
        /// events that have not yet been committed to the chain.
        ///
        /// Currently only a single active subscription is supported. Subscription requests will cancel the active
        /// subscription, if any.
        async fn mempool_subscription(
            &self,
            request: tonic::Request<super::MempoolSubscriptionRequest>,
        ) -> std::result::Result<
            tonic::Response<Self::MempoolSubscriptionStream>,
            tonic::Status,
        >;
    }
    #[derive(Debug)]
    pub struct ApiServer<T> {
        inner: Arc<T>,
        accept_compression_encodings: EnabledCompressionEncodings,
        send_compression_encodings: EnabledCompressionEncodings,
        max_decoding_message_size: Option<usize>,
        max_encoding_message_size: Option<usize>,
    }
    impl<T> ApiServer<T> {
        pub fn new(inner: T) -> Self {
            Self::from_arc(Arc::new(inner))
        }
        pub fn from_arc(inner: Arc<T>) -> Self {
            Self {
                inner,
                accept_compression_encodings: Default::default(),
                send_compression_encodings: Default::default(),
                max_decoding_message_size: None,
                max_encoding_message_size: None,
            }
        }
        pub fn with_interceptor<F>(
            inner: T,
            interceptor: F,
        ) -> InterceptedService<Self, F>
        where
            F: tonic::service::Interceptor,
        {
            InterceptedService::new(Self::new(inner), interceptor)
        }
        /// Enable decompressing requests with the given encoding.
        #[must_use]
        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.accept_compression_encodings.enable(encoding);
            self
        }
        /// Compress responses with the given encoding, if the client supports it.
        #[must_use]
        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.send_compression_encodings.enable(encoding);
            self
        }
        /// Limits the maximum size of a decoded message.
        ///
        /// Default: `4MB`
        #[must_use]
        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
            self.max_decoding_message_size = Some(limit);
            self
        }
        /// Limits the maximum size of an encoded message.
        ///
        /// Default: `usize::MAX`
        #[must_use]
        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
            self.max_encoding_message_size = Some(limit);
            self
        }
    }
    impl<T, B> tonic::codegen::Service<http::Request<B>> for ApiServer<T>
    where
        T: Api,
        B: Body + std::marker::Send + 'static,
        B::Error: Into<StdError> + std::marker::Send + 'static,
    {
        type Response = http::Response<tonic::body::Body>;
        type Error = std::convert::Infallible;
        type Future = BoxFuture<Self::Response, Self::Error>;
        fn poll_ready(
            &mut self,
            _cx: &mut Context<'_>,
        ) -> Poll<std::result::Result<(), Self::Error>> {
            Poll::Ready(Ok(()))
        }
        fn call(&mut self, req: http::Request<B>) -> Self::Future {
            match req.uri().path() {
                "/block_producer.Api/Status" => {
                    #[allow(non_camel_case_types)]
                    struct StatusSvc<T: Api>(pub Arc<T>);
                    impl<T: Api> tonic::server::UnaryService<()> for StatusSvc<T> {
                        type Response = super::BlockProducerStatus;
                        type Future = BoxFuture<
                            tonic::Response<Self::Response>,
                            tonic::Status,
                        >;
                        fn call(&mut self, request: tonic::Request<()>) -> Self::Future {
                            let inner = Arc::clone(&self.0);
                            let fut = async move {
                                <T as Api>::status(&inner, request).await
                            };
                            Box::pin(fut)
                        }
                    }
                    let accept_compression_encodings = self.accept_compression_encodings;
                    let send_compression_encodings = self.send_compression_encodings;
                    let max_decoding_message_size = self.max_decoding_message_size;
                    let max_encoding_message_size = self.max_encoding_message_size;
                    let inner = self.inner.clone();
                    let fut = async move {
                        let method = StatusSvc(inner);
                        let codec = tonic_prost::ProstCodec::default();
                        let mut grpc = tonic::server::Grpc::new(codec)
                            .apply_compression_config(
                                accept_compression_encodings,
                                send_compression_encodings,
                            )
                            .apply_max_message_size_config(
                                max_decoding_message_size,
                                max_encoding_message_size,
                            );
                        let res = grpc.unary(method, req).await;
                        Ok(res)
                    };
                    Box::pin(fut)
                }
                "/block_producer.Api/SubmitProvenTransaction" => {
                    #[allow(non_camel_case_types)]
                    struct SubmitProvenTransactionSvc<T: Api>(pub Arc<T>);
                    impl<
                        T: Api,
                    > tonic::server::UnaryService<
                        super::super::transaction::ProvenTransaction,
                    > for SubmitProvenTransactionSvc<T> {
                        type Response = super::SubmitProvenTransactionResponse;
                        type Future = BoxFuture<
                            tonic::Response<Self::Response>,
                            tonic::Status,
                        >;
                        fn call(
                            &mut self,
                            request: tonic::Request<
                                super::super::transaction::ProvenTransaction,
                            >,
                        ) -> Self::Future {
                            let inner = Arc::clone(&self.0);
                            let fut = async move {
                                <T as Api>::submit_proven_transaction(&inner, request).await
                            };
                            Box::pin(fut)
                        }
                    }
                    let accept_compression_encodings = self.accept_compression_encodings;
                    let send_compression_encodings = self.send_compression_encodings;
                    let max_decoding_message_size = self.max_decoding_message_size;
                    let max_encoding_message_size = self.max_encoding_message_size;
                    let inner = self.inner.clone();
                    let fut = async move {
                        let method = SubmitProvenTransactionSvc(inner);
                        let codec = tonic_prost::ProstCodec::default();
                        let mut grpc = tonic::server::Grpc::new(codec)
                            .apply_compression_config(
                                accept_compression_encodings,
                                send_compression_encodings,
                            )
                            .apply_max_message_size_config(
                                max_decoding_message_size,
                                max_encoding_message_size,
                            );
                        let res = grpc.unary(method, req).await;
                        Ok(res)
                    };
                    Box::pin(fut)
                }
                "/block_producer.Api/SubmitProvenBatch" => {
                    #[allow(non_camel_case_types)]
                    struct SubmitProvenBatchSvc<T: Api>(pub Arc<T>);
                    impl<
                        T: Api,
                    > tonic::server::UnaryService<
                        super::super::transaction::ProvenTransactionBatch,
                    > for SubmitProvenBatchSvc<T> {
                        type Response = super::SubmitProvenBatchResponse;
                        type Future = BoxFuture<
                            tonic::Response<Self::Response>,
                            tonic::Status,
                        >;
                        fn call(
                            &mut self,
                            request: tonic::Request<
                                super::super::transaction::ProvenTransactionBatch,
                            >,
                        ) -> Self::Future {
                            let inner = Arc::clone(&self.0);
                            let fut = async move {
                                <T as Api>::submit_proven_batch(&inner, request).await
                            };
                            Box::pin(fut)
                        }
                    }
                    let accept_compression_encodings = self.accept_compression_encodings;
                    let send_compression_encodings = self.send_compression_encodings;
                    let max_decoding_message_size = self.max_decoding_message_size;
                    let max_encoding_message_size = self.max_encoding_message_size;
                    let inner = self.inner.clone();
                    let fut = async move {
                        let method = SubmitProvenBatchSvc(inner);
                        let codec = tonic_prost::ProstCodec::default();
                        let mut grpc = tonic::server::Grpc::new(codec)
                            .apply_compression_config(
                                accept_compression_encodings,
                                send_compression_encodings,
                            )
                            .apply_max_message_size_config(
                                max_decoding_message_size,
                                max_encoding_message_size,
                            );
                        let res = grpc.unary(method, req).await;
                        Ok(res)
                    };
                    Box::pin(fut)
                }
                "/block_producer.Api/MempoolSubscription" => {
                    #[allow(non_camel_case_types)]
                    struct MempoolSubscriptionSvc<T: Api>(pub Arc<T>);
                    impl<
                        T: Api,
                    > tonic::server::ServerStreamingService<
                        super::MempoolSubscriptionRequest,
                    > for MempoolSubscriptionSvc<T> {
                        type Response = super::MempoolEvent;
                        type ResponseStream = T::MempoolSubscriptionStream;
                        type Future = BoxFuture<
                            tonic::Response<Self::ResponseStream>,
                            tonic::Status,
                        >;
                        fn call(
                            &mut self,
                            request: tonic::Request<super::MempoolSubscriptionRequest>,
                        ) -> Self::Future {
                            let inner = Arc::clone(&self.0);
                            let fut = async move {
                                <T as Api>::mempool_subscription(&inner, request).await
                            };
                            Box::pin(fut)
                        }
                    }
                    let accept_compression_encodings = self.accept_compression_encodings;
                    let send_compression_encodings = self.send_compression_encodings;
                    let max_decoding_message_size = self.max_decoding_message_size;
                    let max_encoding_message_size = self.max_encoding_message_size;
                    let inner = self.inner.clone();
                    let fut = async move {
                        let method = MempoolSubscriptionSvc(inner);
                        let codec = tonic_prost::ProstCodec::default();
                        let mut grpc = tonic::server::Grpc::new(codec)
                            .apply_compression_config(
                                accept_compression_encodings,
                                send_compression_encodings,
                            )
                            .apply_max_message_size_config(
                                max_decoding_message_size,
                                max_encoding_message_size,
                            );
                        let res = grpc.server_streaming(method, req).await;
                        Ok(res)
                    };
                    Box::pin(fut)
                }
                _ => {
                    Box::pin(async move {
                        let mut response = http::Response::new(
                            tonic::body::Body::default(),
                        );
                        let headers = response.headers_mut();
                        headers
                            .insert(
                                tonic::Status::GRPC_STATUS,
                                (tonic::Code::Unimplemented as i32).into(),
                            );
                        headers
                            .insert(
                                http::header::CONTENT_TYPE,
                                tonic::metadata::GRPC_CONTENT_TYPE,
                            );
                        Ok(response)
                    })
                }
            }
        }
    }
    impl<T> Clone for ApiServer<T> {
        fn clone(&self) -> Self {
            let inner = self.inner.clone();
            Self {
                inner,
                accept_compression_encodings: self.accept_compression_encodings,
                send_compression_encodings: self.send_compression_encodings,
                max_decoding_message_size: self.max_decoding_message_size,
                max_encoding_message_size: self.max_encoding_message_size,
            }
        }
    }
    /// Generated gRPC service name
    pub const SERVICE_NAME: &str = "block_producer.Api";
    impl<T> tonic::server::NamedService for ApiServer<T> {
        const NAME: &'static str = SERVICE_NAME;
    }
}
