use massa_proto_rs::massa::api::v1 as grpc_api;
use crate::private::{
add_staking_secret_keys, add_to_bootstrap_blacklist, add_to_bootstrap_whitelist,
add_to_peers_whitelist, allow_everyone_to_bootstrap, ban_nodes_by_ids, ban_nodes_by_ips,
get_bootstrap_blacklist, get_bootstrap_whitelist, get_mip_status, get_node_status,
get_peers_whitelist, remove_from_bootstrap_blacklist, remove_from_bootstrap_whitelist,
remove_from_peers_whitelist, remove_staking_addresses, shutdown_gracefully, sign_messages,
unban_nodes_by_ids, unban_nodes_by_ips,
};
use crate::public::{
execute_read_only_call, get_blocks, get_datastore_entries, get_endorsements,
get_next_block_best_parents, get_operations, get_sc_execution_events, get_selector_draws,
get_stakers, get_status, get_transactions_throughput, query_state, search_blocks,
search_endorsements, search_operations,
};
#[cfg(feature = "execution-trace")]
use crate::public::{get_operation_abi_call_stacks, get_slot_abi_call_stacks, get_slot_transfers};
#[cfg(feature = "execution-trace")]
use crate::stream::new_slot_transfers::new_slot_transfers;
use crate::server::{MassaPrivateGrpc, MassaPublicGrpc};
use crate::stream::{
new_blocks::{new_blocks, NewBlocksStreamType},
new_endorsements::{new_endorsements, NewEndorsementsStreamType},
new_filled_blocks::{new_filled_blocks, NewFilledBlocksStreamType},
new_operations::{new_operations, NewOperationsStreamType},
new_slot_abi_call_stacks::{new_slot_abi_call_stacks, NewSlotABICallStacksStreamType},
new_slot_execution_outputs::{new_slot_execution_outputs, NewSlotExecutionOutputsStreamType},
new_slot_transfers::NewSlotTransfersStreamType,
send_blocks::SendBlocksStreamType,
send_endorsements::{send_endorsements, SendEndorsementsStreamType},
send_operations::{send_operations, SendOperationsStreamType},
tx_throughput::{transactions_throughput, TransactionsThroughputStreamType},
};
#[tonic::async_trait]
impl grpc_api::public_service_server::PublicService for MassaPublicGrpc {
async fn execute_read_only_call(
&self,
request: tonic::Request<grpc_api::ExecuteReadOnlyCallRequest>,
) -> std::result::Result<tonic::Response<grpc_api::ExecuteReadOnlyCallResponse>, tonic::Status>
{
Ok(tonic::Response::new(execute_read_only_call(self, request)?))
}
#[cfg(feature = "execution-trace")]
async fn get_operation_abi_call_stacks(
&self,
request: tonic::Request<grpc_api::GetOperationAbiCallStacksRequest>,
) -> std::result::Result<
tonic::Response<grpc_api::GetOperationAbiCallStacksResponse>,
tonic::Status,
> {
Ok(tonic::Response::new(get_operation_abi_call_stacks(
self, request,
)?))
}
#[cfg(not(feature = "execution-trace"))]
async fn get_operation_abi_call_stacks(
&self,
_request: tonic::Request<grpc_api::GetOperationAbiCallStacksRequest>,
) -> std::result::Result<
tonic::Response<grpc_api::GetOperationAbiCallStacksResponse>,
tonic::Status,
> {
Err(tonic::Status::unimplemented("feature not enabled"))
}
#[cfg(feature = "execution-trace")]
async fn get_slot_abi_call_stacks(
&self,
request: tonic::Request<grpc_api::GetSlotAbiCallStacksRequest>,
) -> std::result::Result<tonic::Response<grpc_api::GetSlotAbiCallStacksResponse>, tonic::Status>
{
Ok(tonic::Response::new(get_slot_abi_call_stacks(
self, request,
)?))
}
#[cfg(not(feature = "execution-trace"))]
async fn get_slot_abi_call_stacks(
&self,
_request: tonic::Request<grpc_api::GetSlotAbiCallStacksRequest>,
) -> std::result::Result<tonic::Response<grpc_api::GetSlotAbiCallStacksResponse>, tonic::Status>
{
Err(tonic::Status::unimplemented("feature not enabled"))
}
#[cfg(feature = "execution-trace")]
async fn get_slot_transfers(
&self,
request: tonic::Request<grpc_api::GetSlotTransfersRequest>,
) -> std::result::Result<tonic::Response<grpc_api::GetSlotTransfersResponse>, tonic::Status>
{
Ok(tonic::Response::new(get_slot_transfers(self, request)?))
}
#[cfg(not(feature = "execution-trace"))]
async fn get_slot_transfers(
&self,
_request: tonic::Request<grpc_api::GetSlotTransfersRequest>,
) -> std::result::Result<tonic::Response<grpc_api::GetSlotTransfersResponse>, tonic::Status>
{
Err(tonic::Status::unimplemented("feature not enabled"))
}
async fn get_blocks(
&self,
request: tonic::Request<grpc_api::GetBlocksRequest>,
) -> Result<tonic::Response<grpc_api::GetBlocksResponse>, tonic::Status> {
Ok(tonic::Response::new(get_blocks(self, request)?))
}
async fn get_datastore_entries(
&self,
request: tonic::Request<grpc_api::GetDatastoreEntriesRequest>,
) -> Result<tonic::Response<grpc_api::GetDatastoreEntriesResponse>, tonic::Status> {
Ok(tonic::Response::new(get_datastore_entries(self, request)?))
}
async fn get_endorsements(
&self,
request: tonic::Request<grpc_api::GetEndorsementsRequest>,
) -> Result<tonic::Response<grpc_api::GetEndorsementsResponse>, tonic::Status> {
Ok(tonic::Response::new(get_endorsements(self, request)?))
}
async fn get_stakers(
&self,
request: tonic::Request<grpc_api::GetStakersRequest>,
) -> Result<tonic::Response<grpc_api::GetStakersResponse>, tonic::Status> {
Ok(tonic::Response::new(get_stakers(self, request)?))
}
async fn get_status(
&self,
request: tonic::Request<grpc_api::GetStatusRequest>,
) -> Result<tonic::Response<grpc_api::GetStatusResponse>, tonic::Status> {
Ok(tonic::Response::new(get_status(self, request)?))
}
async fn get_next_block_best_parents(
&self,
request: tonic::Request<grpc_api::GetNextBlockBestParentsRequest>,
) -> Result<tonic::Response<grpc_api::GetNextBlockBestParentsResponse>, tonic::Status> {
Ok(tonic::Response::new(get_next_block_best_parents(
self, request,
)?))
}
async fn get_operations(
&self,
request: tonic::Request<grpc_api::GetOperationsRequest>,
) -> Result<tonic::Response<grpc_api::GetOperationsResponse>, tonic::Status> {
Ok(tonic::Response::new(get_operations(self, request)?))
}
async fn get_sc_execution_events(
&self,
request: tonic::Request<grpc_api::GetScExecutionEventsRequest>,
) -> Result<tonic::Response<grpc_api::GetScExecutionEventsResponse>, tonic::Status> {
Ok(tonic::Response::new(get_sc_execution_events(
self, request,
)?))
}
async fn get_selector_draws(
&self,
request: tonic::Request<grpc_api::GetSelectorDrawsRequest>,
) -> Result<tonic::Response<grpc_api::GetSelectorDrawsResponse>, tonic::Status> {
Ok(tonic::Response::new(get_selector_draws(self, request)?))
}
async fn get_transactions_throughput(
&self,
request: tonic::Request<grpc_api::GetTransactionsThroughputRequest>,
) -> Result<tonic::Response<grpc_api::GetTransactionsThroughputResponse>, tonic::Status> {
Ok(tonic::Response::new(get_transactions_throughput(
self, request,
)?))
}
async fn query_state(
&self,
request: tonic::Request<grpc_api::QueryStateRequest>,
) -> Result<tonic::Response<grpc_api::QueryStateResponse>, tonic::Status> {
Ok(tonic::Response::new(query_state(self, request)?))
}
async fn search_blocks(
&self,
request: tonic::Request<grpc_api::SearchBlocksRequest>,
) -> Result<tonic::Response<grpc_api::SearchBlocksResponse>, tonic::Status> {
Ok(tonic::Response::new(search_blocks(self, request)?))
}
async fn search_endorsements(
&self,
request: tonic::Request<grpc_api::SearchEndorsementsRequest>,
) -> Result<tonic::Response<grpc_api::SearchEndorsementsResponse>, tonic::Status> {
Ok(tonic::Response::new(search_endorsements(self, request)?))
}
async fn search_operations(
&self,
request: tonic::Request<grpc_api::SearchOperationsRequest>,
) -> Result<tonic::Response<grpc_api::SearchOperationsResponse>, tonic::Status> {
Ok(tonic::Response::new(search_operations(self, request)?))
}
type NewBlocksStream = NewBlocksStreamType;
async fn new_blocks(
&self,
request: tonic::Request<tonic::Streaming<grpc_api::NewBlocksRequest>>,
) -> Result<tonic::Response<Self::NewBlocksStream>, tonic::Status> {
Ok(tonic::Response::new(new_blocks(self, request).await?))
}
type NewEndorsementsStream = NewEndorsementsStreamType;
async fn new_endorsements(
&self,
request: tonic::Request<tonic::Streaming<grpc_api::NewEndorsementsRequest>>,
) -> Result<tonic::Response<Self::NewEndorsementsStream>, tonic::Status> {
Ok(tonic::Response::new(new_endorsements(self, request).await?))
}
type NewFilledBlocksStream = NewFilledBlocksStreamType;
async fn new_filled_blocks(
&self,
request: tonic::Request<tonic::Streaming<grpc_api::NewFilledBlocksRequest>>,
) -> Result<tonic::Response<Self::NewFilledBlocksStream>, tonic::Status> {
Ok(tonic::Response::new(
new_filled_blocks(self, request).await?,
))
}
type NewOperationsStream = NewOperationsStreamType;
async fn new_operations(
&self,
request: tonic::Request<tonic::Streaming<grpc_api::NewOperationsRequest>>,
) -> Result<tonic::Response<Self::NewOperationsStream>, tonic::Status> {
Ok(tonic::Response::new(new_operations(self, request).await?))
}
type NewSlotExecutionOutputsStream = NewSlotExecutionOutputsStreamType;
async fn new_slot_execution_outputs(
&self,
request: tonic::Request<tonic::Streaming<grpc_api::NewSlotExecutionOutputsRequest>>,
) -> Result<tonic::Response<Self::NewSlotExecutionOutputsStream>, tonic::Status> {
Ok(tonic::Response::new(
new_slot_execution_outputs(self, request).await?,
))
}
type NewSlotTransfersStream = NewSlotTransfersStreamType;
#[cfg(feature = "execution-trace")]
async fn new_slot_transfers(
&self,
request: tonic::Request<tonic::Streaming<grpc_api::NewSlotTransfersRequest>>,
) -> Result<tonic::Response<Self::NewSlotTransfersStream>, tonic::Status> {
Ok(tonic::Response::new(
new_slot_transfers(self, request).await?,
))
}
#[cfg(not(feature = "execution-trace"))]
async fn new_slot_transfers(
&self,
_request: tonic::Request<tonic::Streaming<grpc_api::NewSlotTransfersRequest>>,
) -> Result<tonic::Response<Self::NewSlotTransfersStream>, tonic::Status> {
Err(tonic::Status::unimplemented("feature not enabled"))
}
type NewSlotABICallStacksStream = NewSlotABICallStacksStreamType;
async fn new_slot_abi_call_stacks(
&self,
request: tonic::Request<tonic::Streaming<grpc_api::NewSlotAbiCallStacksRequest>>,
) -> Result<tonic::Response<Self::NewSlotABICallStacksStream>, tonic::Status> {
if cfg!(feature = "execution-trace") {
Ok(tonic::Response::new(
new_slot_abi_call_stacks(self, request).await?,
))
} else {
Err(tonic::Status::unimplemented("feature not enabled"))
}
}
type SendBlocksStream = SendBlocksStreamType;
async fn send_blocks(
&self,
_request: tonic::Request<tonic::Streaming<grpc_api::SendBlocksRequest>>,
) -> Result<tonic::Response<Self::SendBlocksStream>, tonic::Status> {
Err(tonic::Status::unavailable("not available"))
}
type SendEndorsementsStream = SendEndorsementsStreamType;
async fn send_endorsements(
&self,
request: tonic::Request<tonic::Streaming<grpc_api::SendEndorsementsRequest>>,
) -> Result<tonic::Response<Self::SendEndorsementsStream>, tonic::Status> {
Ok(tonic::Response::new(
send_endorsements(self, request).await?,
))
}
type SendOperationsStream = SendOperationsStreamType;
async fn send_operations(
&self,
request: tonic::Request<tonic::Streaming<grpc_api::SendOperationsRequest>>,
) -> Result<tonic::Response<Self::SendOperationsStream>, tonic::Status> {
Ok(tonic::Response::new(send_operations(self, request).await?))
}
type TransactionsThroughputStream = TransactionsThroughputStreamType;
async fn transactions_throughput(
&self,
request: tonic::Request<tonic::Streaming<grpc_api::TransactionsThroughputRequest>>,
) -> Result<tonic::Response<Self::TransactionsThroughputStream>, tonic::Status> {
Ok(tonic::Response::new(
transactions_throughput(self, request).await?,
))
}
}
#[tonic::async_trait]
impl grpc_api::private_service_server::PrivateService for MassaPrivateGrpc {
async fn add_to_bootstrap_blacklist(
&self,
request: tonic::Request<grpc_api::AddToBootstrapBlacklistRequest>,
) -> Result<tonic::Response<grpc_api::AddToBootstrapBlacklistResponse>, tonic::Status> {
Ok(tonic::Response::new(add_to_bootstrap_blacklist(
self, request,
)?))
}
async fn add_to_bootstrap_whitelist(
&self,
request: tonic::Request<grpc_api::AddToBootstrapWhitelistRequest>,
) -> Result<tonic::Response<grpc_api::AddToBootstrapWhitelistResponse>, tonic::Status> {
Ok(tonic::Response::new(add_to_bootstrap_whitelist(
self, request,
)?))
}
async fn add_to_peers_whitelist(
&self,
request: tonic::Request<grpc_api::AddToPeersWhitelistRequest>,
) -> Result<tonic::Response<grpc_api::AddToPeersWhitelistResponse>, tonic::Status> {
Ok(tonic::Response::new(add_to_peers_whitelist(self, request)?))
}
async fn add_staking_secret_keys(
&self,
request: tonic::Request<grpc_api::AddStakingSecretKeysRequest>,
) -> Result<tonic::Response<grpc_api::AddStakingSecretKeysResponse>, tonic::Status> {
Ok(tonic::Response::new(add_staking_secret_keys(
self, request,
)?))
}
async fn ban_nodes_by_ids(
&self,
request: tonic::Request<grpc_api::BanNodesByIdsRequest>,
) -> Result<tonic::Response<grpc_api::BanNodesByIdsResponse>, tonic::Status> {
Ok(tonic::Response::new(ban_nodes_by_ids(self, request)?))
}
async fn ban_nodes_by_ips(
&self,
request: tonic::Request<grpc_api::BanNodesByIpsRequest>,
) -> Result<tonic::Response<grpc_api::BanNodesByIpsResponse>, tonic::Status> {
Ok(tonic::Response::new(ban_nodes_by_ips(self, request)?))
}
async fn get_bootstrap_blacklist(
&self,
request: tonic::Request<grpc_api::GetBootstrapBlacklistRequest>,
) -> Result<tonic::Response<grpc_api::GetBootstrapBlacklistResponse>, tonic::Status> {
Ok(tonic::Response::new(get_bootstrap_blacklist(
self, request,
)?))
}
async fn get_bootstrap_whitelist(
&self,
request: tonic::Request<grpc_api::GetBootstrapWhitelistRequest>,
) -> Result<tonic::Response<grpc_api::GetBootstrapWhitelistResponse>, tonic::Status> {
Ok(tonic::Response::new(get_bootstrap_whitelist(
self, request,
)?))
}
async fn get_mip_status(
&self,
request: tonic::Request<grpc_api::GetMipStatusRequest>,
) -> Result<tonic::Response<grpc_api::GetMipStatusResponse>, tonic::Status> {
Ok(tonic::Response::new(get_mip_status(self, request)?))
}
async fn allow_everyone_to_bootstrap(
&self,
request: tonic::Request<grpc_api::AllowEveryoneToBootstrapRequest>,
) -> Result<tonic::Response<grpc_api::AllowEveryoneToBootstrapResponse>, tonic::Status> {
Ok(tonic::Response::new(allow_everyone_to_bootstrap(
self, request,
)?))
}
async fn get_node_status(
&self,
request: tonic::Request<grpc_api::GetNodeStatusRequest>,
) -> Result<tonic::Response<grpc_api::GetNodeStatusResponse>, tonic::Status> {
Ok(tonic::Response::new(get_node_status(self, request)?))
}
async fn get_peers_whitelist(
&self,
request: tonic::Request<grpc_api::GetPeersWhitelistRequest>,
) -> Result<tonic::Response<grpc_api::GetPeersWhitelistResponse>, tonic::Status> {
Ok(tonic::Response::new(get_peers_whitelist(self, request)?))
}
async fn remove_from_bootstrap_blacklist(
&self,
request: tonic::Request<grpc_api::RemoveFromBootstrapBlacklistRequest>,
) -> Result<tonic::Response<grpc_api::RemoveFromBootstrapBlacklistResponse>, tonic::Status>
{
Ok(tonic::Response::new(remove_from_bootstrap_blacklist(
self, request,
)?))
}
async fn remove_from_bootstrap_whitelist(
&self,
request: tonic::Request<grpc_api::RemoveFromBootstrapWhitelistRequest>,
) -> Result<tonic::Response<grpc_api::RemoveFromBootstrapWhitelistResponse>, tonic::Status>
{
Ok(tonic::Response::new(remove_from_bootstrap_whitelist(
self, request,
)?))
}
async fn remove_from_peers_whitelist(
&self,
request: tonic::Request<grpc_api::RemoveFromPeersWhitelistRequest>,
) -> Result<tonic::Response<grpc_api::RemoveFromPeersWhitelistResponse>, tonic::Status> {
Ok(tonic::Response::new(remove_from_peers_whitelist(
self, request,
)?))
}
async fn remove_staking_addresses(
&self,
request: tonic::Request<grpc_api::RemoveStakingAddressesRequest>,
) -> Result<tonic::Response<grpc_api::RemoveStakingAddressesResponse>, tonic::Status> {
Ok(tonic::Response::new(remove_staking_addresses(
self, request,
)?))
}
async fn sign_messages(
&self,
request: tonic::Request<grpc_api::SignMessagesRequest>,
) -> Result<tonic::Response<grpc_api::SignMessagesResponse>, tonic::Status> {
Ok(tonic::Response::new(sign_messages(self, request)?))
}
async fn shutdown_gracefully(
&self,
request: tonic::Request<grpc_api::ShutdownGracefullyRequest>,
) -> Result<tonic::Response<grpc_api::ShutdownGracefullyResponse>, tonic::Status> {
Ok(tonic::Response::new(shutdown_gracefully(self, request)?))
}
async fn unban_nodes_by_ids(
&self,
request: tonic::Request<grpc_api::UnbanNodesByIdsRequest>,
) -> Result<tonic::Response<grpc_api::UnbanNodesByIdsResponse>, tonic::Status> {
Ok(tonic::Response::new(unban_nodes_by_ids(self, request)?))
}
async fn unban_nodes_by_ips(
&self,
request: tonic::Request<grpc_api::UnbanNodesByIpsRequest>,
) -> Result<tonic::Response<grpc_api::UnbanNodesByIpsResponse>, tonic::Status> {
Ok(tonic::Response::new(unban_nodes_by_ips(self, request)?))
}
}