interface: readme intro
Some checks are pending
Audit / audit (push) Waiting to run
Deny / audit (push) Waiting to run

This commit is contained in:
hinto.janai 2024-07-25 20:45:22 -04:00
parent b5b39b63a9
commit d7379eadf6
No known key found for this signature in database
GPG key ID: D47CE05FA175A499
4 changed files with 42 additions and 8 deletions

View file

@ -46,7 +46,6 @@ opt-level = 1
opt-level = 3
[workspace.dependencies]
axum = { version = "0.7.5", 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 }

View file

@ -17,7 +17,7 @@ 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 }
axum = { workspace = true, features = ["json"] }
axum = { version = "0.7.5", features = ["json"], default-features = false }
serde = { workspace = true }
tower = { workspace = true }
paste = { workspace = true }

View file

@ -1,6 +1,40 @@
TODO
# `cuprate-rpc-interface`
This crate provides Cuprate's RPC _interface_.
# What
```text
cuprate-rpc-interface provides these parts
┌────┴────┐
┌───────────────────────────┤ ├───────────────────┐
▼ ▼ ▼ ▼
CLIENT -> ROUTE -> REQUEST -> HANDLER -> RESPONSE -> CLIENT
▲ ▲
└───┬───┘
You provide this part
```
Everything coming _in_ from a client including:
- Any lower-level HTTP stuff
- Endpoint routing
- Request (de)serialization
is handled by this crate.
This is where your [`RpcHandler`] turns this [`Request`] into a [`Response`].
You hand this `Response` back to `cuprate-rpc-interface` and it will take care of sending it back to the client.
The main handler used by Cuprate is implemented in the `cuprate-rpc-handler` crate;
it implements the regular RPC server modeled after `monerod`.
# Router
# Requests, responses, and errors
# The RPC handler [`Service`](tower::Service)
# Routes
# Feature flags
List of feature flags for `cuprate-rpc-interface`.

View file

@ -9,13 +9,14 @@ use crate::{
};
//---------------------------------------------------------------------------------------------------- Router
/// Create the RPC router.
///
/// TODO
#[allow(clippy::needless_pass_by_value)]
///
/// # Routes
/// List of `monerod` routes, [here](https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.h#L97-L189).
#[rustfmt::skip]
pub fn create_router<H: RpcHandler>() -> Router<H> {
// List of `monerod` routes:
// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.h#L97-L189>
Router::new()
// JSON-RPC route.
.route("/json_rpc", get(json::json_rpc::<H>))