From 7e4015a38180f8f3dd172fd342d86e18f08b590d Mon Sep 17 00:00:00 2001 From: "hinto.janai" Date: Fri, 6 Sep 2024 18:06:50 -0400 Subject: [PATCH 1/3] replace `RpcError` with `anyhow::Error` --- Cargo.lock | 1 - Cargo.toml | 1 + rpc/interface/Cargo.toml | 2 +- rpc/interface/README.md | 9 +++--- rpc/interface/src/lib.rs | 2 -- rpc/interface/src/rpc_error.rs | 53 -------------------------------- rpc/interface/src/rpc_handler.rs | 2 +- rpc/interface/src/rpc_service.rs | 12 +++----- 8 files changed, 13 insertions(+), 69 deletions(-) delete mode 100644 rpc/interface/src/rpc_error.rs diff --git a/Cargo.lock b/Cargo.lock index 426fced1..3ca5d6af 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -800,7 +800,6 @@ name = "cuprate-rpc-interface" version = "0.0.0" dependencies = [ "axum", - "cuprate-database", "cuprate-epee-encoding", "cuprate-helper", "cuprate-json-rpc", diff --git a/Cargo.toml b/Cargo.toml index 8704cb78..2d718936 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,6 +48,7 @@ opt-level = 1 opt-level = 3 [workspace.dependencies] +anyhow = { version = "1.0.87", default-features = false } async-trait = { version = "0.1.74", default-features = false } bitflags = { version = "2.4.2", default-features = false } borsh = { version = "1.2.1", default-features = false } diff --git a/rpc/interface/Cargo.toml b/rpc/interface/Cargo.toml index 56f3fd49..feb1affb 100644 --- a/rpc/interface/Cargo.toml +++ b/rpc/interface/Cargo.toml @@ -17,8 +17,8 @@ cuprate-epee-encoding = { path = "../../net/epee-encoding", default-features = f cuprate-json-rpc = { path = "../json-rpc", default-features = false } cuprate-rpc-types = { path = "../types", features = ["serde", "epee"], default-features = false } cuprate-helper = { path = "../../helper", features = ["asynch"], default-features = false } -cuprate-database = { path = "../../storage/database" } +anyhow = { workspace = true } axum = { version = "0.7.5", features = ["json"], default-features = false } serde = { workspace = true, optional = true } tower = { workspace = true } diff --git a/rpc/interface/README.md b/rpc/interface/README.md index eb878643..fa5496c1 100644 --- a/rpc/interface/README.md +++ b/rpc/interface/README.md @@ -45,15 +45,16 @@ The proper usage of this crate is to: This is your [`tower::Service`] that converts `Request`s into `Response`s, i.e. the "inner handler". -Said concretely, `RpcHandler` is 3 `tower::Service`s where the request/response types are -the 3 endpoint enums from [`cuprate_rpc_types`] and the error type is from this crate: +Said concretely, `RpcHandler` is 3 `tower::Service`s where the +request/response types are the 3 endpoint enums from [`cuprate_rpc_types`]: - [`JsonRpcRequest`](cuprate_rpc_types::json::JsonRpcRequest) & [`JsonRpcResponse`](cuprate_rpc_types::json::JsonRpcResponse) - [`BinRequest`](cuprate_rpc_types::bin::BinRequest) & [`BinResponse`](cuprate_rpc_types::bin::BinRequest) - [`OtherRequest`](cuprate_rpc_types::other::OtherRequest) & [`OtherResponse`](cuprate_rpc_types::other::OtherRequest) -- [`RpcError`] `RpcHandler`'s [`Future`](std::future::Future) is generic, _although_, -it must output `Result<$RESPONSE, RpcError>`. +it must output `Result<$RESPONSE, anyhow::Error>`. + +The error type must always be [`anyhow::Error`]. The `RpcHandler` must also hold some state that is required for RPC server operation. diff --git a/rpc/interface/src/lib.rs b/rpc/interface/src/lib.rs index ebea4939..1f84738e 100644 --- a/rpc/interface/src/lib.rs +++ b/rpc/interface/src/lib.rs @@ -3,14 +3,12 @@ mod route; mod router_builder; -mod rpc_error; mod rpc_handler; #[cfg(feature = "dummy")] mod rpc_handler_dummy; mod rpc_service; pub use router_builder::RouterBuilder; -pub use rpc_error::RpcError; pub use rpc_handler::RpcHandler; #[cfg(feature = "dummy")] pub use rpc_handler_dummy::RpcHandlerDummy; diff --git a/rpc/interface/src/rpc_error.rs b/rpc/interface/src/rpc_error.rs deleted file mode 100644 index 59f371ab..00000000 --- a/rpc/interface/src/rpc_error.rs +++ /dev/null @@ -1,53 +0,0 @@ -//! RPC errors. - -//---------------------------------------------------------------------------------------------------- Import -use axum::http::StatusCode; - -use cuprate_database::RuntimeError; - -//---------------------------------------------------------------------------------------------------- RpcError -/// Possible errors during RPC operation. -/// -/// These are any errors that can happen _during_ a handler function. -/// I.e. if this error surfaces, it happened _after_ the request was -/// deserialized. -/// -/// This is the `Error` type required to be used in an [`RpcHandler`](crate::RpcHandler). -/// -/// TODO: This is empty as possible errors will be -/// enumerated when the handler functions are created. -#[derive(Debug, thiserror::Error)] -pub enum RpcError { - /// A [`std::io::Error`] from the database. - #[error("database I/O error: {0}")] - DatabaseIo(#[from] std::io::Error), - - /// A (non-I/O related) database error. - #[error("database error: {0}")] - DatabaseError(RuntimeError), -} - -impl From for StatusCode { - fn from(_: RpcError) -> Self { - // TODO - Self::INTERNAL_SERVER_ERROR - } -} - -impl From for RpcError { - fn from(error: RuntimeError) -> Self { - match error { - RuntimeError::Io(io) => Self::DatabaseIo(io), - RuntimeError::KeyExists - | RuntimeError::KeyNotFound - | RuntimeError::ResizeNeeded - | RuntimeError::TableNotFound => Self::DatabaseError(error), - } - } -} - -//---------------------------------------------------------------------------------------------------- Tests -#[cfg(test)] -mod test { - // use super::*; -} diff --git a/rpc/interface/src/rpc_handler.rs b/rpc/interface/src/rpc_handler.rs index 1299ec48..1d2676c7 100644 --- a/rpc/interface/src/rpc_handler.rs +++ b/rpc/interface/src/rpc_handler.rs @@ -22,7 +22,7 @@ use crate::RpcService; /// In other words, an [`RpcHandler`] is a type that implements [`tower::Service`] 3 times, /// one for each request/response enum type found in [`cuprate_rpc_types`]. /// -/// The error type must always be [`RpcError`](crate::RpcError). +/// The error type must always be [`anyhow::Error`]. /// /// See this crate's `RpcHandlerDummy` for an implementation example of this trait. /// diff --git a/rpc/interface/src/rpc_service.rs b/rpc/interface/src/rpc_service.rs index b85ac047..285d60ba 100644 --- a/rpc/interface/src/rpc_service.rs +++ b/rpc/interface/src/rpc_service.rs @@ -5,8 +5,6 @@ use std::future::Future; use tower::Service; -use crate::rpc_error::RpcError; - //---------------------------------------------------------------------------------------------------- RpcService /// An RPC [`tower::Service`]. /// @@ -17,7 +15,7 @@ use crate::rpc_error::RpcError; /// The `Request` and `Response` are generic and /// are used in the [`tower::Service`] bounds. /// -/// The error type is always [`RpcError`]. +/// The error type is always [`anyhow::Error`]. /// /// There is a blanket implementation that implements this /// trait on types that implement `tower::Service` correctly. @@ -31,8 +29,8 @@ pub trait RpcService: + Service< Request, Response = Response, - Error = RpcError, - Future: Future> + Send + 'static, + Error = anyhow::Error, + Future: Future> + Send + 'static, > { } @@ -45,8 +43,8 @@ impl RpcService for T where + Service< Request, Response = Response, - Error = RpcError, - Future: Future> + Send + 'static, + Error = anyhow::Error, + Future: Future> + Send + 'static, > { } From aac1a31bedffe2e795821935bc345b5060e2a10c Mon Sep 17 00:00:00 2001 From: "hinto.janai" Date: Fri, 6 Sep 2024 20:09:21 -0400 Subject: [PATCH 2/3] interface: update error --- rpc/interface/Cargo.toml | 1 - rpc/interface/src/route/bin.rs | 19 +++++++++++++++++-- rpc/interface/src/route/json_rpc.rs | 4 +++- rpc/interface/src/route/other.rs | 4 +++- rpc/interface/src/rpc_handler_dummy.rs | 25 +++++++++++++------------ 5 files changed, 36 insertions(+), 17 deletions(-) diff --git a/rpc/interface/Cargo.toml b/rpc/interface/Cargo.toml index feb1affb..42d10554 100644 --- a/rpc/interface/Cargo.toml +++ b/rpc/interface/Cargo.toml @@ -22,7 +22,6 @@ anyhow = { workspace = true } axum = { version = "0.7.5", features = ["json"], default-features = false } serde = { workspace = true, optional = true } tower = { workspace = true } -thiserror = { workspace = true } paste = { workspace = true } futures = { workspace = true } diff --git a/rpc/interface/src/route/bin.rs b/rpc/interface/src/route/bin.rs index 45447caf..90d06c8f 100644 --- a/rpc/interface/src/route/bin.rs +++ b/rpc/interface/src/route/bin.rs @@ -5,7 +5,14 @@ use axum::{body::Bytes, extract::State, http::StatusCode}; use tower::ServiceExt; use cuprate_epee_encoding::from_bytes; -use cuprate_rpc_types::bin::{BinRequest, BinResponse, GetTransactionPoolHashesRequest}; +use cuprate_rpc_types::{ + bin::{ + BinRequest, BinResponse, GetBlocksByHeightRequest, GetBlocksRequest, GetHashesRequest, + GetOutputIndexesRequest, GetOutsRequest, GetTransactionPoolHashesRequest, + }, + json::GetOutputDistributionRequest, + RpcCall, +}; use crate::rpc_handler::RpcHandler; @@ -66,8 +73,16 @@ macro_rules! generate_endpoints_inner { ($variant:ident, $handler:ident, $request:expr) => { paste::paste! { { + // Check if restricted. + if [<$variant Request>]::IS_RESTRICTED && $handler.restricted() { + // TODO: mimic `monerod` behavior. + return Err(StatusCode::FORBIDDEN); + } + // Send request. - let response = $handler.oneshot($request).await?; + let Ok(response) = $handler.oneshot($request).await else { + return Err(StatusCode::INTERNAL_SERVER_ERROR); + }; let BinResponse::$variant(response) = response else { panic!("RPC handler returned incorrect response"); diff --git a/rpc/interface/src/route/json_rpc.rs b/rpc/interface/src/route/json_rpc.rs index bf3d937d..7efb8513 100644 --- a/rpc/interface/src/route/json_rpc.rs +++ b/rpc/interface/src/route/json_rpc.rs @@ -50,7 +50,9 @@ pub(crate) async fn json_rpc( } // Send request. - let response = handler.oneshot(request.body).await?; + let Ok(response) = handler.oneshot(request.body).await else { + return Err(StatusCode::INTERNAL_SERVER_ERROR); + }; Ok(Json(Response::ok(id, response))) } diff --git a/rpc/interface/src/route/other.rs b/rpc/interface/src/route/other.rs index 129ddd59..3ff84487 100644 --- a/rpc/interface/src/route/other.rs +++ b/rpc/interface/src/route/other.rs @@ -82,7 +82,9 @@ macro_rules! generate_endpoints_inner { // Send request. let request = OtherRequest::$variant($request); - let response = $handler.oneshot(request).await?; + let Ok(response) = $handler.oneshot(request).await else { + return Err(StatusCode::INTERNAL_SERVER_ERROR); + }; let OtherResponse::$variant(response) = response else { panic!("RPC handler returned incorrect response") diff --git a/rpc/interface/src/rpc_handler_dummy.rs b/rpc/interface/src/rpc_handler_dummy.rs index 06fa4608..0b018354 100644 --- a/rpc/interface/src/rpc_handler_dummy.rs +++ b/rpc/interface/src/rpc_handler_dummy.rs @@ -3,19 +3,20 @@ //---------------------------------------------------------------------------------------------------- Use use std::task::Poll; -use cuprate_rpc_types::{ - bin::{BinRequest, BinResponse}, - json::{JsonRpcRequest, JsonRpcResponse}, - other::{OtherRequest, OtherResponse}, -}; +use anyhow::Error; use futures::channel::oneshot::channel; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use tower::Service; use cuprate_helper::asynch::InfallibleOneshotReceiver; +use cuprate_rpc_types::{ + bin::{BinRequest, BinResponse}, + json::{JsonRpcRequest, JsonRpcResponse}, + other::{OtherRequest, OtherResponse}, +}; -use crate::{rpc_error::RpcError, rpc_handler::RpcHandler}; +use crate::rpc_handler::RpcHandler; //---------------------------------------------------------------------------------------------------- RpcHandlerDummy /// An [`RpcHandler`] that always returns [`Default::default`]. @@ -45,8 +46,8 @@ impl RpcHandler for RpcHandlerDummy { impl Service for RpcHandlerDummy { type Response = JsonRpcResponse; - type Error = RpcError; - type Future = InfallibleOneshotReceiver>; + type Error = Error; + type Future = InfallibleOneshotReceiver>; fn poll_ready(&mut self, _: &mut std::task::Context<'_>) -> Poll> { Poll::Ready(Ok(())) @@ -100,8 +101,8 @@ impl Service for RpcHandlerDummy { impl Service for RpcHandlerDummy { type Response = BinResponse; - type Error = RpcError; - type Future = InfallibleOneshotReceiver>; + type Error = Error; + type Future = InfallibleOneshotReceiver>; fn poll_ready(&mut self, _: &mut std::task::Context<'_>) -> Poll> { Poll::Ready(Ok(())) @@ -130,8 +131,8 @@ impl Service for RpcHandlerDummy { impl Service for RpcHandlerDummy { type Response = OtherResponse; - type Error = RpcError; - type Future = InfallibleOneshotReceiver>; + type Error = Error; + type Future = InfallibleOneshotReceiver>; fn poll_ready(&mut self, _: &mut std::task::Context<'_>) -> Poll> { Poll::Ready(Ok(())) From 6b16fb5688487f56af04c30419c374678cbe9b22 Mon Sep 17 00:00:00 2001 From: "hinto.janai" Date: Fri, 6 Sep 2024 20:09:42 -0400 Subject: [PATCH 3/3] cuprated: update error type --- Cargo.lock | 9 +++- binaries/cuprated/Cargo.toml | 1 + binaries/cuprated/src/rpc/bin.rs | 19 +++++---- binaries/cuprated/src/rpc/handler.rs | 15 ++++--- binaries/cuprated/src/rpc/json.rs | 64 ++++++++++++++-------------- binaries/cuprated/src/rpc/other.rs | 59 ++++++++++++------------- 6 files changed, 89 insertions(+), 78 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3ca5d6af..0bb4612a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -56,6 +56,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" +[[package]] +name = "anyhow" +version = "1.0.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f00e1f6e58a40e807377c75c6a7f97bf9044fab57816f2414e6f5f4499d7b8" + [[package]] name = "async-stream" version = "0.3.5" @@ -799,6 +805,7 @@ dependencies = [ name = "cuprate-rpc-interface" version = "0.0.0" dependencies = [ + "anyhow", "axum", "cuprate-epee-encoding", "cuprate-helper", @@ -809,7 +816,6 @@ dependencies = [ "paste", "serde", "serde_json", - "thiserror", "tokio", "tower", "ureq", @@ -910,6 +916,7 @@ dependencies = [ name = "cuprated" version = "0.1.0" dependencies = [ + "anyhow", "async-trait", "bitflags 2.5.0", "borsh", diff --git a/binaries/cuprated/Cargo.toml b/binaries/cuprated/Cargo.toml index 63a04317..a886c124 100644 --- a/binaries/cuprated/Cargo.toml +++ b/binaries/cuprated/Cargo.toml @@ -35,6 +35,7 @@ cuprate-rpc-interface = { path = "../../rpc/interface" } cuprate-rpc-types = { path = "../../rpc/types" } # TODO: after v1.0.0, remove unneeded dependencies. +anyhow = { workspace = true } async-trait = { workspace = true } bitflags = { workspace = true } borsh = { workspace = true } diff --git a/binaries/cuprated/src/rpc/bin.rs b/binaries/cuprated/src/rpc/bin.rs index a4bbabbb..60d92c12 100644 --- a/binaries/cuprated/src/rpc/bin.rs +++ b/binaries/cuprated/src/rpc/bin.rs @@ -1,4 +1,5 @@ -use cuprate_rpc_interface::RpcError; +use anyhow::Error; + use cuprate_rpc_types::{ bin::{ BinRequest, BinResponse, GetBlocksByHeightRequest, GetBlocksByHeightResponse, @@ -15,7 +16,7 @@ use crate::rpc::CupratedRpcHandlerState; pub(super) async fn map_request( state: CupratedRpcHandlerState, request: BinRequest, -) -> Result { +) -> Result { use BinRequest as Req; use BinResponse as Resp; @@ -37,48 +38,48 @@ pub(super) async fn map_request( async fn get_blocks( state: CupratedRpcHandlerState, request: GetBlocksRequest, -) -> Result { +) -> Result { todo!() } async fn get_blocks_by_height( state: CupratedRpcHandlerState, request: GetBlocksByHeightRequest, -) -> Result { +) -> Result { todo!() } async fn get_hashes( state: CupratedRpcHandlerState, request: GetHashesRequest, -) -> Result { +) -> Result { todo!() } async fn get_output_indexes( state: CupratedRpcHandlerState, request: GetOutputIndexesRequest, -) -> Result { +) -> Result { todo!() } async fn get_outs( state: CupratedRpcHandlerState, request: GetOutsRequest, -) -> Result { +) -> Result { todo!() } async fn get_transaction_pool_hashes( state: CupratedRpcHandlerState, request: GetTransactionPoolHashesRequest, -) -> Result { +) -> Result { todo!() } async fn get_output_distribution( state: CupratedRpcHandlerState, request: GetOutputDistributionRequest, -) -> Result { +) -> Result { todo!() } diff --git a/binaries/cuprated/src/rpc/handler.rs b/binaries/cuprated/src/rpc/handler.rs index ab15ff6b..8ba25eab 100644 --- a/binaries/cuprated/src/rpc/handler.rs +++ b/binaries/cuprated/src/rpc/handler.rs @@ -2,6 +2,7 @@ use std::task::{Context, Poll}; +use anyhow::Error; use futures::{channel::oneshot::channel, future::BoxFuture}; use serde::{Deserialize, Serialize}; use tower::Service; @@ -9,7 +10,7 @@ use tower::Service; use cuprate_blockchain::service::BlockchainReadHandle; use cuprate_helper::asynch::InfallibleOneshotReceiver; use cuprate_json_rpc::Id; -use cuprate_rpc_interface::{RpcError, RpcHandler}; +use cuprate_rpc_interface::RpcHandler; use cuprate_rpc_types::{ bin::{BinRequest, BinResponse}, json::{JsonRpcRequest, JsonRpcResponse}, @@ -58,8 +59,8 @@ impl RpcHandler for CupratedRpcHandler { impl Service for CupratedRpcHandler { type Response = JsonRpcResponse; - type Error = RpcError; - type Future = BoxFuture<'static, Result>; + type Error = Error; + type Future = BoxFuture<'static, Result>; fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) @@ -73,8 +74,8 @@ impl Service for CupratedRpcHandler { impl Service for CupratedRpcHandler { type Response = BinResponse; - type Error = RpcError; - type Future = BoxFuture<'static, Result>; + type Error = Error; + type Future = BoxFuture<'static, Result>; fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) @@ -88,8 +89,8 @@ impl Service for CupratedRpcHandler { impl Service for CupratedRpcHandler { type Response = OtherResponse; - type Error = RpcError; - type Future = BoxFuture<'static, Result>; + type Error = Error; + type Future = BoxFuture<'static, Result>; fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) diff --git a/binaries/cuprated/src/rpc/json.rs b/binaries/cuprated/src/rpc/json.rs index ece925e8..41398d48 100644 --- a/binaries/cuprated/src/rpc/json.rs +++ b/binaries/cuprated/src/rpc/json.rs @@ -1,8 +1,8 @@ use std::sync::Arc; +use anyhow::Error; use tower::ServiceExt; -use cuprate_rpc_interface::RpcError; use cuprate_rpc_types::json::{ AddAuxPowRequest, AddAuxPowResponse, BannedRequest, BannedResponse, CalcPowRequest, CalcPowResponse, FlushCacheRequest, FlushCacheResponse, FlushTransactionPoolRequest, @@ -29,7 +29,7 @@ use crate::rpc::CupratedRpcHandlerState; pub(super) async fn map_request( state: CupratedRpcHandlerState, request: JsonRpcRequest, -) -> Result { +) -> Result { use JsonRpcRequest as Req; use JsonRpcResponse as Resp; @@ -86,209 +86,209 @@ pub(super) async fn map_request( async fn get_block_count( state: CupratedRpcHandlerState, request: GetBlockCountRequest, -) -> Result { +) -> Result { todo!() } async fn on_get_block_hash( state: CupratedRpcHandlerState, request: OnGetBlockHashRequest, -) -> Result { +) -> Result { todo!() } async fn submit_block( state: CupratedRpcHandlerState, request: SubmitBlockRequest, -) -> Result { +) -> Result { todo!() } async fn generate_blocks( state: CupratedRpcHandlerState, request: GenerateBlocksRequest, -) -> Result { +) -> Result { todo!() } async fn get_last_block_header( state: CupratedRpcHandlerState, request: GetLastBlockHeaderRequest, -) -> Result { +) -> Result { todo!() } async fn get_block_header_by_hash( state: CupratedRpcHandlerState, request: GetBlockHeaderByHashRequest, -) -> Result { +) -> Result { todo!() } async fn get_block_header_by_height( state: CupratedRpcHandlerState, request: GetBlockHeaderByHeightRequest, -) -> Result { +) -> Result { todo!() } async fn get_block_headers_range( state: CupratedRpcHandlerState, request: GetBlockHeadersRangeRequest, -) -> Result { +) -> Result { todo!() } async fn get_block( state: CupratedRpcHandlerState, request: GetBlockRequest, -) -> Result { +) -> Result { todo!() } async fn get_connections( state: CupratedRpcHandlerState, request: GetConnectionsRequest, -) -> Result { +) -> Result { todo!() } async fn get_info( state: CupratedRpcHandlerState, request: GetInfoRequest, -) -> Result { +) -> Result { todo!() } async fn hard_fork_info( state: CupratedRpcHandlerState, request: HardForkInfoRequest, -) -> Result { +) -> Result { todo!() } async fn set_bans( state: CupratedRpcHandlerState, request: SetBansRequest, -) -> Result { +) -> Result { todo!() } async fn get_bans( state: CupratedRpcHandlerState, request: GetBansRequest, -) -> Result { +) -> Result { todo!() } async fn banned( state: CupratedRpcHandlerState, request: BannedRequest, -) -> Result { +) -> Result { todo!() } async fn flush_transaction_pool( state: CupratedRpcHandlerState, request: FlushTransactionPoolRequest, -) -> Result { +) -> Result { todo!() } async fn get_output_histogram( state: CupratedRpcHandlerState, request: GetOutputHistogramRequest, -) -> Result { +) -> Result { todo!() } async fn get_coinbase_tx_sum( state: CupratedRpcHandlerState, request: GetCoinbaseTxSumRequest, -) -> Result { +) -> Result { todo!() } async fn get_version( state: CupratedRpcHandlerState, request: GetVersionRequest, -) -> Result { +) -> Result { todo!() } async fn get_fee_estimate( state: CupratedRpcHandlerState, request: GetFeeEstimateRequest, -) -> Result { +) -> Result { todo!() } async fn get_alternate_chains( state: CupratedRpcHandlerState, request: GetAlternateChainsRequest, -) -> Result { +) -> Result { todo!() } async fn relay_tx( state: CupratedRpcHandlerState, request: RelayTxRequest, -) -> Result { +) -> Result { todo!() } async fn sync_info( state: CupratedRpcHandlerState, request: SyncInfoRequest, -) -> Result { +) -> Result { todo!() } async fn get_transaction_pool_backlog( state: CupratedRpcHandlerState, request: GetTransactionPoolBacklogRequest, -) -> Result { +) -> Result { todo!() } async fn get_miner_data( state: CupratedRpcHandlerState, request: GetMinerDataRequest, -) -> Result { +) -> Result { todo!() } async fn prune_blockchain( state: CupratedRpcHandlerState, request: PruneBlockchainRequest, -) -> Result { +) -> Result { todo!() } async fn calc_pow( state: CupratedRpcHandlerState, request: CalcPowRequest, -) -> Result { +) -> Result { todo!() } async fn flush_cache( state: CupratedRpcHandlerState, request: FlushCacheRequest, -) -> Result { +) -> Result { todo!() } async fn add_aux_pow( state: CupratedRpcHandlerState, request: AddAuxPowRequest, -) -> Result { +) -> Result { todo!() } async fn get_tx_ids_loose( state: CupratedRpcHandlerState, request: GetTxIdsLooseRequest, -) -> Result { +) -> Result { todo!() } diff --git a/binaries/cuprated/src/rpc/other.rs b/binaries/cuprated/src/rpc/other.rs index b23ebdf9..c0df3993 100644 --- a/binaries/cuprated/src/rpc/other.rs +++ b/binaries/cuprated/src/rpc/other.rs @@ -1,4 +1,5 @@ -use cuprate_rpc_interface::RpcError; +use anyhow::Error; + use cuprate_rpc_types::other::{ GetAltBlocksHashesRequest, GetAltBlocksHashesResponse, GetHeightRequest, GetHeightResponse, GetLimitRequest, GetLimitResponse, GetNetStatsRequest, GetNetStatsResponse, GetOutsRequest, @@ -22,7 +23,7 @@ use crate::rpc::CupratedRpcHandlerState; pub(super) async fn map_request( state: CupratedRpcHandlerState, request: OtherRequest, -) -> Result { +) -> Result { use OtherRequest as Req; use OtherResponse as Resp; @@ -72,188 +73,188 @@ pub(super) async fn map_request( async fn get_height( state: CupratedRpcHandlerState, request: GetHeightRequest, -) -> Result { +) -> Result { todo!() } async fn get_transactions( state: CupratedRpcHandlerState, request: GetTransactionsRequest, -) -> Result { +) -> Result { todo!() } async fn get_alt_blocks_hashes( state: CupratedRpcHandlerState, request: GetAltBlocksHashesRequest, -) -> Result { +) -> Result { todo!() } async fn is_key_image_spent( state: CupratedRpcHandlerState, request: IsKeyImageSpentRequest, -) -> Result { +) -> Result { todo!() } async fn send_raw_transaction( state: CupratedRpcHandlerState, request: SendRawTransactionRequest, -) -> Result { +) -> Result { todo!() } async fn start_mining( state: CupratedRpcHandlerState, request: StartMiningRequest, -) -> Result { +) -> Result { todo!() } async fn stop_mining( state: CupratedRpcHandlerState, request: StopMiningRequest, -) -> Result { +) -> Result { todo!() } async fn mining_status( state: CupratedRpcHandlerState, request: MiningStatusRequest, -) -> Result { +) -> Result { todo!() } async fn save_bc( state: CupratedRpcHandlerState, request: SaveBcRequest, -) -> Result { +) -> Result { todo!() } async fn get_peer_list( state: CupratedRpcHandlerState, request: GetPeerListRequest, -) -> Result { +) -> Result { todo!() } async fn set_log_hash_rate( state: CupratedRpcHandlerState, request: SetLogHashRateRequest, -) -> Result { +) -> Result { todo!() } async fn set_log_level( state: CupratedRpcHandlerState, request: SetLogLevelRequest, -) -> Result { +) -> Result { todo!() } async fn set_log_categories( state: CupratedRpcHandlerState, request: SetLogCategoriesRequest, -) -> Result { +) -> Result { todo!() } async fn set_bootstrap_daemon( state: CupratedRpcHandlerState, request: SetBootstrapDaemonRequest, -) -> Result { +) -> Result { todo!() } async fn get_transaction_pool( state: CupratedRpcHandlerState, request: GetTransactionPoolRequest, -) -> Result { +) -> Result { todo!() } async fn get_transaction_pool_stats( state: CupratedRpcHandlerState, request: GetTransactionPoolStatsRequest, -) -> Result { +) -> Result { todo!() } async fn stop_daemon( state: CupratedRpcHandlerState, request: StopDaemonRequest, -) -> Result { +) -> Result { todo!() } async fn get_limit( state: CupratedRpcHandlerState, request: GetLimitRequest, -) -> Result { +) -> Result { todo!() } async fn set_limit( state: CupratedRpcHandlerState, request: SetLimitRequest, -) -> Result { +) -> Result { todo!() } async fn out_peers( state: CupratedRpcHandlerState, request: OutPeersRequest, -) -> Result { +) -> Result { todo!() } async fn in_peers( state: CupratedRpcHandlerState, request: InPeersRequest, -) -> Result { +) -> Result { todo!() } async fn get_net_stats( state: CupratedRpcHandlerState, request: GetNetStatsRequest, -) -> Result { +) -> Result { todo!() } async fn get_outs( state: CupratedRpcHandlerState, request: GetOutsRequest, -) -> Result { +) -> Result { todo!() } async fn update( state: CupratedRpcHandlerState, request: UpdateRequest, -) -> Result { +) -> Result { todo!() } async fn pop_blocks( state: CupratedRpcHandlerState, request: PopBlocksRequest, -) -> Result { +) -> Result { todo!() } async fn get_transaction_pool_hashes( state: CupratedRpcHandlerState, request: GetTransactionPoolHashesRequest, -) -> Result { +) -> Result { todo!() } async fn get_public_nodes( state: CupratedRpcHandlerState, request: GetPublicNodesRequest, -) -> Result { +) -> Result { todo!() }