diff --git a/binaries/cuprated/src/rpc.rs b/binaries/cuprated/src/rpc.rs index 773da807..efbe72e8 100644 --- a/binaries/cuprated/src/rpc.rs +++ b/binaries/cuprated/src/rpc.rs @@ -2,6 +2,9 @@ //! //! Will contain the code to initiate the RPC and a request handler. +mod bin; mod handler; +mod json; +mod other; pub use handler::CupratedRpcHandler; diff --git a/binaries/cuprated/src/rpc/bin.rs b/binaries/cuprated/src/rpc/bin.rs new file mode 100644 index 00000000..bb99da76 --- /dev/null +++ b/binaries/cuprated/src/rpc/bin.rs @@ -0,0 +1,67 @@ +use cuprate_rpc_types::bin::{ + GetBlocksByHeightRequest, GetBlocksByHeightResponse, GetBlocksRequest, GetBlocksResponse, + GetHashesRequest, GetHashesResponse, GetOutputDistributionRequest, + GetOutputDistributionResponse, GetOutputIndexesRequest, GetOutputIndexesResponse, + GetOutsRequest, GetOutsResponse, GetTransactionPoolHashesRequest, + GetTransactionPoolHashesResponse, +}; + +use crate::rpc::CupratedRpcHandler; + +async fn map_request(state: CupratedRpcHandler, request: BinRpcRequest) -> BinRpcResponse { + use BinRpcRequest as Req; + use BinRpcResponse as Resp; + + match request { + Req::GetBlocks(r) => Resp::GetBlocks(get_blocks(state, r)), + Req::GetBlocksByHeight(r) => Resp::GetBlocksByHeight(get_blocks_by_height(state, r)), + Req::GetHashes(r) => Resp::GetHashes(get_hashes(state, r)), + Req::GetOutputIndexes(r) => Resp::GetOutputIndexes(get_output_indexes(state, r)), + Req::GetOuts(r) => Resp::GetOuts(get_outs(state, r)), + Req::GetTransactionPoolHashes(r) => { + Resp::GetTransactionPoolHashes(get_transaction_pool_hashes(state, r)) + } + Req::GetOutputDistribution(r) => { + Resp::GetOutputDistribution(get_output_distribution(state, r)) + } + } +} + +async fn get_blocks(state: CupratedRpcHandler, request: GetBlocksRequest) -> GetBlocksResponse { + todo!() +} + +async fn get_blocks_by_height( + state: CupratedRpcHandler, + request: GetBlocksByHeightRequest, +) -> GetBlocksByHeightResponse { + todo!() +} + +async fn get_hashes(state: CupratedRpcHandler, request: GetHashesRequest) -> GetHashesResponse { + todo!() +} + +async fn get_output_indexes( + state: CupratedRpcHandler, + request: GetOutputIndexesRequest, +) -> GetOutputIndexesResponse { + todo!() +} + +async fn get_outs(state: CupratedRpcHandler, request: GetOutsRequest) -> GetOutsResponse { + todo!() +} + +async fn get_transaction_pool_hashes( + state: CupratedRpcHandler, + request: GetTransactionPoolHashesRequest, +) -> GetTransactionPoolHashesResponse { + todo!() +} +async fn get_output_distribution( + state: CupratedRpcHandler, + request: GetOutputDistributionRequest, +) -> GetOutputDistributionResponse { + todo!() +} diff --git a/binaries/cuprated/src/rpc/handler.rs b/binaries/cuprated/src/rpc/handler.rs index fd17a105..b2506159 100644 --- a/binaries/cuprated/src/rpc/handler.rs +++ b/binaries/cuprated/src/rpc/handler.rs @@ -7,9 +7,13 @@ use futures::channel::oneshot::channel; use serde::{Deserialize, Serialize}; use tower::Service; +use cuprate_blockchain::service::{BlockchainReadHandle, BlockchainWriteHandle}; use cuprate_helper::asynch::InfallibleOneshotReceiver; use cuprate_json_rpc::Id; use cuprate_rpc_interface::{RpcError, RpcHandler, RpcRequest, RpcResponse}; +use cuprate_txpool::service::{TxpoolReadHandle, TxpoolWriteHandle}; + +use crate::rpc::{bin, json, other}; //---------------------------------------------------------------------------------------------------- CupratedRpcHandler /// TODO @@ -17,8 +21,23 @@ use cuprate_rpc_interface::{RpcError, RpcHandler, RpcRequest, RpcResponse}; pub struct CupratedRpcHandler { /// Should this RPC server be [restricted](RpcHandler::restricted)? pub restricted: bool, + + /// Read handle to the blockchain database. + pub blockchain_read: BlockchainReadHandle, + /// Write handle to the blockchain database. + pub blockchain_write: BlockchainWriteHandle, + /// Direct handle to the blockchain database. + pub blockchain_db: Arc, + + /// Read handle to the transaction pool database. + pub txpool_read: TxpoolReadHandle, + /// Write handle to the transaction pool database. + pub txpool_write: TxpoolWriteHandle, + /// Direct handle to the transaction pool database. + pub txpool_db: Arc, } +//---------------------------------------------------------------------------------------------------- RpcHandler Impl impl RpcHandler for CupratedRpcHandler { fn restricted(&self) -> bool { self.restricted @@ -42,84 +61,19 @@ impl Service for CupratedRpcHandler { use cuprate_rpc_types::other::OtherRequest as OReq; use cuprate_rpc_types::other::OtherResponse as OResp; - #[rustfmt::skip] - #[allow(clippy::default_trait_access)] + // INVARIANT: + // + // We don't need to check for `self.is_restricted()` + // here because `cuprate-rpc-interface` handles that. + // + // We can assume the request coming has the required permissions. + + let state = CupratedRpcHandler::clone(self); + let resp = match req { - // JSON-RPC 2.0 requests. - RpcRequest::JsonRpc(j) => RpcResponse::JsonRpc(cuprate_json_rpc::Response::ok(Id::Null, match j.body { - JReq::GetBlockCount(_) => JResp::GetBlockCount(Default::default()), - JReq::OnGetBlockHash(_) => JResp::OnGetBlockHash(Default::default()), - JReq::SubmitBlock(_) => JResp::SubmitBlock(Default::default()), - JReq::GenerateBlocks(_) => JResp::GenerateBlocks(Default::default()), - JReq::GetLastBlockHeader(_) => JResp::GetLastBlockHeader(Default::default()), - JReq::GetBlockHeaderByHash(_) => JResp::GetBlockHeaderByHash(Default::default()), - JReq::GetBlockHeaderByHeight(_) => JResp::GetBlockHeaderByHeight(Default::default()), - JReq::GetBlockHeadersRange(_) => JResp::GetBlockHeadersRange(Default::default()), - JReq::GetBlock(_) => JResp::GetBlock(Default::default()), - JReq::GetConnections(_) => JResp::GetConnections(Default::default()), - JReq::GetInfo(_) => JResp::GetInfo(Default::default()), - JReq::HardForkInfo(_) => JResp::HardForkInfo(Default::default()), - JReq::SetBans(_) => JResp::SetBans(Default::default()), - JReq::GetBans(_) => JResp::GetBans(Default::default()), - JReq::Banned(_) => JResp::Banned(Default::default()), - JReq::FlushTransactionPool(_) => JResp::FlushTransactionPool(Default::default()), - JReq::GetOutputHistogram(_) => JResp::GetOutputHistogram(Default::default()), - JReq::GetCoinbaseTxSum(_) => JResp::GetCoinbaseTxSum(Default::default()), - JReq::GetVersion(_) => JResp::GetVersion(Default::default()), - JReq::GetFeeEstimate(_) => JResp::GetFeeEstimate(Default::default()), - JReq::GetAlternateChains(_) => JResp::GetAlternateChains(Default::default()), - JReq::RelayTx(_) => JResp::RelayTx(Default::default()), - JReq::SyncInfo(_) => JResp::SyncInfo(Default::default()), - JReq::GetTransactionPoolBacklog(_) => JResp::GetTransactionPoolBacklog(Default::default()), - JReq::GetMinerData(_) => JResp::GetMinerData(Default::default()), - JReq::PruneBlockchain(_) => JResp::PruneBlockchain(Default::default()), - JReq::CalcPow(_) => JResp::CalcPow(Default::default()), - JReq::FlushCache(_) => JResp::FlushCache(Default::default()), - JReq::AddAuxPow(_) => JResp::AddAuxPow(Default::default()), - JReq::GetTxIdsLoose(_) => JResp::GetTxIdsLoose(Default::default()), - })), - - // Binary requests. - RpcRequest::Binary(b) => RpcResponse::Binary(match b { - BReq::GetBlocks(_) => BResp::GetBlocks(Default::default()), - BReq::GetBlocksByHeight(_) => BResp::GetBlocksByHeight(Default::default()), - BReq::GetHashes(_) => BResp::GetHashes(Default::default()), - BReq::GetOutputIndexes(_) => BResp::GetOutputIndexes(Default::default()), - BReq::GetOuts(_) => BResp::GetOuts(Default::default()), - BReq::GetTransactionPoolHashes(_) => BResp::GetTransactionPoolHashes(Default::default()), - BReq::GetOutputDistribution(_) => BResp::GetOutputDistribution(Default::default()), - }), - - // JSON (but not JSON-RPC) requests. - RpcRequest::Other(o) => RpcResponse::Other(match o { - OReq::GetHeight(_) => OResp::GetHeight(Default::default()), - OReq::GetTransactions(_) => OResp::GetTransactions(Default::default()), - OReq::GetAltBlocksHashes(_) => OResp::GetAltBlocksHashes(Default::default()), - OReq::IsKeyImageSpent(_) => OResp::IsKeyImageSpent(Default::default()), - OReq::SendRawTransaction(_) => OResp::SendRawTransaction(Default::default()), - OReq::StartMining(_) => OResp::StartMining(Default::default()), - OReq::StopMining(_) => OResp::StopMining(Default::default()), - OReq::MiningStatus(_) => OResp::MiningStatus(Default::default()), - OReq::SaveBc(_) => OResp::SaveBc(Default::default()), - OReq::GetPeerList(_) => OResp::GetPeerList(Default::default()), - OReq::SetLogHashRate(_) => OResp::SetLogHashRate(Default::default()), - OReq::SetLogLevel(_) => OResp::SetLogLevel(Default::default()), - OReq::SetLogCategories(_) => OResp::SetLogCategories(Default::default()), - OReq::SetBootstrapDaemon(_) => OResp::SetBootstrapDaemon(Default::default()), - OReq::GetTransactionPool(_) => OResp::GetTransactionPool(Default::default()), - OReq::GetTransactionPoolStats(_) => OResp::GetTransactionPoolStats(Default::default()), - OReq::StopDaemon(_) => OResp::StopDaemon(Default::default()), - OReq::GetLimit(_) => OResp::GetLimit(Default::default()), - OReq::SetLimit(_) => OResp::SetLimit(Default::default()), - OReq::OutPeers(_) => OResp::OutPeers(Default::default()), - OReq::InPeers(_) => OResp::InPeers(Default::default()), - OReq::GetNetStats(_) => OResp::GetNetStats(Default::default()), - OReq::GetOuts(_) => OResp::GetOuts(Default::default()), - OReq::Update(_) => OResp::Update(Default::default()), - OReq::PopBlocks(_) => OResp::PopBlocks(Default::default()), - OReq::GetTransactionPoolHashes(_) => OResp::GetTransactionPoolHashes(Default::default()), - OReq::GetPublicNodes(_) => OResp::GetPublicNodes(Default::default()), - }) + RpcRequest::JsonRpc(r) => json::map_request(r), // JSON-RPC 2.0 requests. + RpcRequest::Binary(r) => bin::map_request(r), // Binary requests. + RpcRequest::Other(o) => other::map_request(r), // JSON (but not JSON-RPC) requests. }; let (tx, rx) = channel(); diff --git a/binaries/cuprated/src/rpc/json.rs b/binaries/cuprated/src/rpc/json.rs new file mode 100644 index 00000000..3286100f --- /dev/null +++ b/binaries/cuprated/src/rpc/json.rs @@ -0,0 +1,248 @@ +use std::sync::Arc; + +use cuprate_rpc_types::json::{ + AddAuxPowRequest, AddAuxPowResponse, BannedRequest, BannedResponse, CalcPowRequest, + CalcPowResponse, FlushCacheRequest, FlushCacheResponse, FlushTransactionPoolRequest, + FlushTransactionPoolResponse, GenerateBlocksRequest, GenerateBlocksResponse, + GetAlternateChainsRequest, GetAlternateChainsResponse, GetBansRequest, GetBansResponse, + GetBlockCountRequest, GetBlockCountResponse, GetBlockHeaderByHashRequest, + GetBlockHeaderByHashResponse, GetBlockHeaderByHeightRequest, GetBlockHeaderByHeightResponse, + GetBlockHeadersRangeRequest, GetBlockHeadersRangeResponse, GetBlockRequest, GetBlockResponse, + GetCoinbaseTxSumRequest, GetCoinbaseTxSumResponse, GetConnectionsRequest, + GetConnectionsResponse, GetFeeEstimateRequest, GetFeeEstimateResponse, GetInfoRequest, + GetInfoResponse, GetLastBlockHeaderRequest, GetLastBlockHeaderResponse, GetMinerDataRequest, + GetMinerDataResponse, GetOutputHistogramRequest, GetOutputHistogramResponse, + GetTransactionPoolBacklogRequest, GetTransactionPoolBacklogResponse, GetTxIdsLooseRequest, + GetTxIdsLooseResponse, GetVersionRequest, GetVersionResponse, HardForkInfoRequest, + HardForkInfoResponse, JsonRpcRequest, JsonRpcResponse, OnGetBlockHashRequest, + OnGetBlockHashResponse, PruneBlockchainRequest, PruneBlockchainResponse, RelayTxRequest, + RelayTxResponse, SetBansRequest, SetBansResponse, SubmitBlockRequest, SubmitBlockResponse, + SyncInfoRequest, SyncInfoResponse, +}; + +use crate::rpc::CupratedRpcHandler; + +async fn map_request(state: CupratedRpcHandler, request: JsonRpcRequest) -> JsonRpcResponse { + use JsonRpcRequest as Req; + use JsonRpcResponse as Resp; + + match request { + Req::GetBlockCount(r) => Resp::GetBlockCount(get_block_count(state, r)), + Req::OnGetBlockHash(r) => Resp::OnGetBlockHash(on_get_block_hash(state, r)), + Req::SubmitBlock(r) => Resp::SubmitBlock(submit_block(state, r)), + Req::GenerateBlocks(r) => Resp::GenerateBlocks(generate_blocks(state, r)), + Req::GetLastBlockHeader(r) => Resp::GetLastBlockHeader(get_last_block_header(state, r)), + Req::GetBlockHeaderByHash(r) => { + Resp::GetBlockHeaderByHash(get_block_header_by_hash(state, r)) + } + Req::GetBlockHeaderByHeight(r) => { + Resp::GetBlockHeaderByHeight(get_block_header_by_height(state, r)) + } + Req::GetBlockHeadersRange(r) => { + Resp::GetBlockHeadersRange(get_block_headers_range(state, r)) + } + Req::GetBlock(r) => Resp::GetBlock(get_block(state, r)), + Req::GetConnections(r) => Resp::GetConnections(get_connections(state, r)), + Req::GetInfo(r) => Resp::GetInfo(get_info(state, r)), + Req::HardForkInfo(r) => Resp::HardForkInfo(hard_fork_info(state, r)), + Req::SetBans(r) => Resp::SetBans(set_bans(state, r)), + Req::GetBans(r) => Resp::GetBans(get_bans(state, r)), + Req::Banned(r) => Resp::Banned(banned(state, r)), + Req::FlushTransactionPool(r) => { + Resp::FlushTransactionPool(flush_transaction_pool(state, r)) + } + Req::GetOutputHistogram(r) => Resp::GetOutputHistogram(get_output_histogram(state, r)), + Req::GetCoinbaseTxSum(r) => Resp::GetCoinbaseTxSum(get_coinbase_tx_sum(state, r)), + Req::GetVersion(r) => Resp::GetVersion(get_version(state, r)), + Req::GetFeeEstimate(r) => Resp::GetFeeEstimate(get_fee_estimate(state, r)), + Req::GetAlternateChains(r) => Resp::GetAlternateChains(get_alternate_chains(state, r)), + Req::RelayTx(r) => Resp::RelayTx(relay_tx(state, r)), + Req::SyncInfo(r) => Resp::SyncInfo(sync_info(state, r)), + Req::GetTransactionPoolBacklog(r) => { + Resp::GetTransactionPoolBacklog(get_transaction_pool_backlog(state, r)) + } + Req::GetMinerData(r) => Resp::GetMinerData(get_miner_data(state, r)), + Req::PruneBlockchain(r) => Resp::PruneBlockchain(prune_blockchain(state, r)), + Req::CalcPow(r) => Resp::CalcPow(calc_pow(state, r)), + Req::FlushCache(r) => Resp::FlushCache(flush_cache(state, r)), + Req::AddAuxPow(r) => Resp::AddAuxPow(add_aux_pow(state, r)), + Req::GetTxIdsLoose(r) => Resp::GetTxIdsLoose(get_tx_ids_loose(state, r)), + } +} + +async fn get_block_count( + state: CupratedRpcHandler, + request: GetBlockCountRequest, +) -> GetBlockCountResponse { + todo!() +} + +async fn on_get_block_hash( + state: CupratedRpcHandler, + request: OnGetBlockHashRequest, +) -> OnGetBlockHashResponse { + todo!() +} + +async fn submit_block( + state: CupratedRpcHandler, + request: SubmitBlockRequest, +) -> SubmitBlockResponse { + todo!() +} + +async fn generate_blocks( + state: CupratedRpcHandler, + request: GenerateBlocksRequest, +) -> GenerateBlocksResponse { + todo!() +} + +async fn get_last_block_header( + state: CupratedRpcHandler, + request: GetLastBlockHeaderRequest, +) -> GetLastBlockHeaderResponse { + todo!() +} + +async fn get_block_header_by_hash( + state: CupratedRpcHandler, + request: GetBlockHeaderByHashRequest, +) -> GetBlockHeaderByHashResponse { + todo!() +} + +async fn get_block_header_by_height( + state: CupratedRpcHandler, + request: GetBlockHeaderByHeightRequest, +) -> GetBlockHeaderByHeightResponse { + todo!() +} + +async fn get_block_headers_range( + state: CupratedRpcHandler, + request: GetBlockHeadersRangeRequest, +) -> GetBlockHeadersRangeResponse { + todo!() +} + +async fn get_block(state: CupratedRpcHandler, request: GetBlockRequest) -> GetBlockResponse { + todo!() +} + +async fn get_connections( + state: CupratedRpcHandler, + request: GetConnectionsRequest, +) -> GetConnectionsResponse { + todo!() +} + +async fn get_info(state: CupratedRpcHandler, request: GetInfoRequest) -> GetInfoResponse { + todo!() +} + +async fn hard_fork_info( + state: CupratedRpcHandler, + request: HardForkInfoRequest, +) -> HardForkInfoResponse { + todo!() +} + +async fn set_bans(state: CupratedRpcHandler, request: SetBansRequest) -> SetBansResponse { + todo!() +} + +async fn get_bans(state: CupratedRpcHandler, request: GetBansRequest) -> GetBansResponse { + todo!() +} + +async fn banned(state: CupratedRpcHandler, request: BannedRequest) -> BannedResponse { + todo!() +} + +async fn flush_transaction_pool( + state: CupratedRpcHandler, + request: FlushTransactionPoolRequest, +) -> FlushTransactionPoolResponse { + todo!() +} + +async fn get_output_histogram( + state: CupratedRpcHandler, + request: GetOutputHistogramRequest, +) -> GetOutputHistogramResponse { + todo!() +} + +async fn get_coinbase_tx_sum( + state: CupratedRpcHandler, + request: GetCoinbaseTxSumRequest, +) -> GetCoinbaseTxSumResponse { + todo!() +} + +async fn get_version(state: CupratedRpcHandler, request: GetVersionRequest) -> GetVersionResponse { + todo!() +} + +async fn get_fee_estimate( + state: CupratedRpcHandler, + request: GetFeeEstimateRequest, +) -> GetFeeEstimateResponse { + todo!() +} + +async fn get_alternate_chains( + state: CupratedRpcHandler, + request: GetAlternateChainsRequest, +) -> GetAlternateChainsResponse { + todo!() +} + +async fn relay_tx(state: CupratedRpcHandler, request: RelayTxRequest) -> RelayTxResponse { + todo!() +} + +async fn sync_info(state: CupratedRpcHandler, request: SyncInfoRequest) -> SyncInfoResponse { + todo!() +} + +async fn get_transaction_pool_backlog( + state: CupratedRpcHandler, + request: GetTransactionPoolBacklogRequest, +) -> GetTransactionPoolBacklogResponse { + todo!() +} + +async fn get_miner_data( + state: CupratedRpcHandler, + request: GetMinerDataRequest, +) -> GetMinerDataResponse { + todo!() +} + +async fn prune_blockchain( + state: CupratedRpcHandler, + request: PruneBlockchainRequest, +) -> PruneBlockchainResponse { + todo!() +} + +async fn calc_pow(state: CupratedRpcHandler, request: CalcPowRequest) -> CalcPowResponse { + todo!() +} + +async fn flush_cache(state: CupratedRpcHandler, request: FlushCacheRequest) -> FlushCacheResponse { + todo!() +} + +async fn add_aux_pow(state: CupratedRpcHandler, request: AddAuxPowRequest) -> AddAuxPowResponse { + todo!() +} + +async fn get_tx_ids_loose( + state: CupratedRpcHandler, + request: GetTxIdsLooseRequest, +) -> GetTxIdsLooseResponse { + todo!() +} diff --git a/binaries/cuprated/src/rpc/other.rs b/binaries/cuprated/src/rpc/other.rs new file mode 100644 index 00000000..f1bb8590 --- /dev/null +++ b/binaries/cuprated/src/rpc/other.rs @@ -0,0 +1,213 @@ +use cuprate_rpc_types::other::{ + GetAltBlocksHashesRequest, GetAltBlocksHashesResponse, GetHeightRequest, GetHeightResponse, + GetLimitRequest, GetLimitResponse, GetNetStatsRequest, GetNetStatsResponse, GetOutsRequest, + GetOutsResponse, GetPeerListRequest, GetPeerListResponse, GetPublicNodesRequest, + GetPublicNodesResponse, GetTransactionPoolHashesRequest, GetTransactionPoolHashesResponse, + GetTransactionPoolRequest, GetTransactionPoolResponse, GetTransactionPoolStatsRequest, + GetTransactionPoolStatsResponse, GetTransactionsRequest, GetTransactionsResponse, + InPeersRequest, InPeersResponse, IsKeyImageSpentRequest, IsKeyImageSpentResponse, + MiningStatusRequest, MiningStatusResponse, OutPeersRequest, OutPeersResponse, PopBlocksRequest, + PopBlocksResponse, SaveBcRequest, SaveBcResponse, SendRawTransactionRequest, + SendRawTransactionResponse, SetBootstrapDaemonRequest, SetBootstrapDaemonResponse, + SetLimitRequest, SetLimitResponse, SetLogCategoriesRequest, SetLogCategoriesResponse, + SetLogHashRateRequest, SetLogHashRateResponse, SetLogLevelRequest, SetLogLevelResponse, + StartMiningRequest, StartMiningResponse, StopDaemonRequest, StopDaemonResponse, + StopMiningRequest, StopMiningResponse, UpdateRequest, UpdateResponse, +}; + +use crate::rpc::CupratedRpcHandler; + +async fn map_request(state: CupratedRpcHandler, request: OtherRpcRequest) -> OtherRpcResponse { + use OtherRpcRequest as Req; + use OtherRpcResponse as Resp; + + match request { + Req::GetHeight(r) => Resp::GetHeight(get_height(state, r)), + Req::GetTransactions(r) => Resp::GetTransactions(get_transactions(state, r)), + Req::GetAltBlocksHashes(r) => Resp::GetAltBlocksHashes(get_alt_blocks_hashes(state, r)), + Req::IsKeyImageSpent(r) => Resp::IsKeyImageSpent(is_key_image_spent(state, r)), + Req::SendRawTransaction(r) => Resp::SendRawTransaction(send_raw_transaction(state, r)), + Req::StartMining(r) => Resp::StartMining(start_mining(state, r)), + Req::StopMining(r) => Resp::StopMining(stop_mining(state, r)), + Req::MiningStatus(r) => Resp::MiningStatus(mining_status(state, r)), + Req::SaveBc(r) => Resp::SaveBc(save_bc(state, r)), + Req::GetPeerList(r) => Resp::GetPeerList(get_peer_list(state, r)), + Req::SetLogHashRate(r) => Resp::SetLogHashRate(set_log_hash_rate(state, r)), + Req::SetLogLevel(r) => Resp::SetLogLevel(set_log_level(state, r)), + Req::SetLogCategories(r) => Resp::SetLogCategories(set_log_categories(state, r)), + Req::SetBootstrapDaemon(r) => Resp::SetBootstrapDaemon(set_bootstrap_daemon(state, r)), + Req::GetTransactionPool(r) => Resp::GetTransactionPool(get_transaction_pool(state, r)), + Req::GetTransactionPoolStats(r) => { + Resp::GetTransactionPoolStats(get_transaction_pool_stats(state, r)) + } + Req::StopDaemon(r) => Resp::StopDaemon(stop_daemon(state, r)), + Req::GetLimit(r) => Resp::GetLimit(get_limit(state, r)), + Req::SetLimit(r) => Resp::SetLimit(set_limit(state, r)), + Req::OutPeers(r) => Resp::OutPeers(out_peers(state, r)), + Req::InPeers(r) => Resp::InPeers(in_peers(state, r)), + Req::GetNetStats(r) => Resp::GetNetStats(get_net_stats(state, r)), + Req::GetOuts(r) => Resp::GetOuts(get_outs(state, r)), + Req::Update(r) => Resp::Update(update(state, r)), + Req::PopBlocks(r) => Resp::PopBlocks(pop_blocks(state, r)), + Req::GetTransactionPoolHashes(r) => { + Resp::GetTransactionPoolHashes(get_transaction_pool_hashes(state, r)) + } + Req::GetPublicNodes(r) => Resp::GetPublicNodes(get_public_nodes(state, r)), + } +} + +async fn get_height(state: CupratedRpcHandler, request: GetHeightRequest) -> GetHeightResponse { + todo!() +} + +async fn get_transactions( + state: CupratedRpcHandler, + request: GetTransactionsRequest, +) -> GetTransactionsResponse { + todo!() +} + +async fn get_alt_blocks_hashes( + state: CupratedRpcHandler, + request: GetAltBlocksHashesRequest, +) -> GetAltBlocksHashesResponse { + todo!() +} + +async fn is_key_image_spent( + state: CupratedRpcHandler, + request: IsKeyImageSpentRequest, +) -> IsKeyImageSpentResponse { + todo!() +} + +async fn send_raw_transaction( + state: CupratedRpcHandler, + request: SendRawTransactionRequest, +) -> SendRawTransactionResponse { + todo!() +} + +async fn start_mining( + state: CupratedRpcHandler, + request: StartMiningRequest, +) -> StartMiningResponse { + todo!() +} + +async fn stop_mining(state: CupratedRpcHandler, request: StopMiningRequest) -> StopMiningResponse { + todo!() +} + +async fn mining_status( + state: CupratedRpcHandler, + request: MiningStatusRequest, +) -> MiningStatusResponse { + todo!() +} + +async fn save_bc(state: CupratedRpcHandler, request: SaveBcRequest) -> SaveBcResponse { + todo!() +} + +async fn get_peer_list( + state: CupratedRpcHandler, + request: GetPeerListRequest, +) -> GetPeerListResponse { + todo!() +} + +async fn set_log_hash_rate( + state: CupratedRpcHandler, + request: SetLogHashRateRequest, +) -> SetLogHashRateResponse { + todo!() +} + +async fn set_log_level( + state: CupratedRpcHandler, + request: SetLogLevelRequest, +) -> SetLogLevelResponse { + todo!() +} + +async fn set_log_categories( + state: CupratedRpcHandler, + request: SetLogCategoriesRequest, +) -> SetLogCategoriesResponse { + todo!() +} + +async fn set_bootstrap_daemon( + state: CupratedRpcHandler, + request: SetBootstrapDaemonRequest, +) -> SetBootstrapDaemonResponse { + todo!() +} + +async fn get_transaction_pool( + state: CupratedRpcHandler, + request: GetTransactionPoolRequest, +) -> GetTransactionPoolResponse { + todo!() +} + +async fn get_transaction_pool_stats( + state: CupratedRpcHandler, + request: GetTransactionPoolStatsRequest, +) -> GetTransactionPoolStatsResponse { + todo!() +} + +async fn stop_daemon(state: CupratedRpcHandler, request: StopDaemonRequest) -> StopDaemonResponse { + todo!() +} + +async fn get_limit(state: CupratedRpcHandler, request: GetLimitRequest) -> GetLimitResponse { + todo!() +} + +async fn set_limit(state: CupratedRpcHandler, request: SetLimitRequest) -> SetLimitResponse { + todo!() +} + +async fn out_peers(state: CupratedRpcHandler, request: OutPeersRequest) -> OutPeersResponse { + todo!() +} + +async fn in_peers(state: CupratedRpcHandler, request: InPeersRequest) -> InPeersResponse { + todo!() +} + +async fn get_net_stats( + state: CupratedRpcHandler, + request: GetNetStatsRequest, +) -> GetNetStatsResponse { + todo!() +} + +async fn get_outs(state: CupratedRpcHandler, request: GetOutsRequest) -> GetOutsResponse { + todo!() +} + +async fn update(state: CupratedRpcHandler, request: UpdateRequest) -> UpdateResponse { + todo!() +} + +async fn pop_blocks(state: CupratedRpcHandler, request: PopBlocksRequest) -> PopBlocksResponse { + todo!() +} + +async fn get_transaction_pool_hashes( + state: CupratedRpcHandler, + request: GetTransactionPoolHashesRequest, +) -> GetTransactionPoolHashesResponse { + todo!() +} + +async fn get_public_nodes( + state: CupratedRpcHandler, + request: GetPublicNodesRequest, +) -> GetPublicNodesResponse { + todo!() +}