changes
Some checks failed
Deny / audit (push) Has been cancelled

This commit is contained in:
hinto.janai 2024-12-25 18:41:12 -05:00
parent c3b35944b0
commit 6b6e32607f
No known key found for this signature in database
GPG key ID: D47CE05FA175A499
5 changed files with 35 additions and 6 deletions

View file

@ -52,7 +52,6 @@ cargo doc --open --package cuprate-blockchain
| [`cuprate-json-rpc`](https://doc.cuprate.org/cuprate_json_rpc) | [`rpc/json-rpc/`](https://github.com/Cuprate/cuprate/tree/main/rpc/json-rpc) | JSON-RPC 2.0 implementation | [`cuprate-json-rpc`](https://doc.cuprate.org/cuprate_json_rpc) | [`rpc/json-rpc/`](https://github.com/Cuprate/cuprate/tree/main/rpc/json-rpc) | JSON-RPC 2.0 implementation
| [`cuprate-rpc-types`](https://doc.cuprate.org/cuprate_rpc_types) | [`rpc/types/`](https://github.com/Cuprate/cuprate/tree/main/rpc/types) | Monero RPC types and traits | [`cuprate-rpc-types`](https://doc.cuprate.org/cuprate_rpc_types) | [`rpc/types/`](https://github.com/Cuprate/cuprate/tree/main/rpc/types) | Monero RPC types and traits
| [`cuprate-rpc-interface`](https://doc.cuprate.org/cuprate_rpc_interface) | [`rpc/interface/`](https://github.com/Cuprate/cuprate/tree/main/rpc/interface) | RPC interface & routing | [`cuprate-rpc-interface`](https://doc.cuprate.org/cuprate_rpc_interface) | [`rpc/interface/`](https://github.com/Cuprate/cuprate/tree/main/rpc/interface) | RPC interface & routing
| [`cuprate-rpc-handler`](https://doc.cuprate.org/cuprate_rpc_handler) | [`rpc/handler/`](https://github.com/Cuprate/cuprate/tree/main/rpc/handler) | RPC inner handlers
## ZMQ ## ZMQ
| Crate | In-tree path | Purpose | | Crate | In-tree path | Purpose |

View file

@ -1,2 +1,8 @@
# The handler # The handler
> TODO: fill after `cuprate-rpc-handler` is created. The handlers (functions that map requests into responses) are / can be generic with `cuprate-rpc-interface`.
The main handlers used by Cuprate is implemented in `cuprated` itself, it implements the standard RPC handlers modeled after `monerod`.
- JSON-RPC handlers: <LINK_TO_FILE>
- Binary handlers: <LINK_TO_FILE>
- Other JSON handlers: <LINK_TO_FILE>

View file

@ -29,8 +29,7 @@ async fn json_rpc(
``` ```
and you provide the function body. and you provide the function body.
The main handler crate is [`cuprate-rpc-handler`](https://doc.cuprate.org/cuprate_rpc_handler). The main handler crate is `cuprated` itself, it implements the standard RPC behavior, i.e. it mostly mirrors `monerod`.
This crate implements the standard RPC behavior, i.e. it mostly mirrors `monerod`.
Although, it's worth noting that other implementations are possible, such as an RPC handler that caches blocks, Although, it's worth noting that other implementations are possible, such as an RPC handler that caches blocks,
or an RPC handler that only accepts certain endpoints, or any combination. or an RPC handler that only accepts certain endpoints, or any combination.

View file

@ -27,4 +27,29 @@ The main components that make up Cuprate's RPC are noted below, alongside the eq
| [`cuprate-json-rpc`](https://doc.cuprate.org/cuprate_json_rpc) | [`jsonrpc_structs.h`](https://github.com/monero-project/monero/blob/caa62bc9ea1c5f2ffe3ffa440ad230e1de509bfd/contrib/epee/include/net/jsonrpc_structs.h), [`http_server_handlers_map2.h`](https://github.com/monero-project/monero/blob/caa62bc9ea1c5f2ffe3ffa440ad230e1de509bfd/contrib/epee/include/net/http_server_handlers_map2.h) | JSON-RPC 2.0 implementation | `monerod`'s JSON-RPC 2.0 handling is spread across a few files. The first defines some data structures, the second contains macros that (essentially) implement JSON-RPC 2.0. | [`cuprate-json-rpc`](https://doc.cuprate.org/cuprate_json_rpc) | [`jsonrpc_structs.h`](https://github.com/monero-project/monero/blob/caa62bc9ea1c5f2ffe3ffa440ad230e1de509bfd/contrib/epee/include/net/jsonrpc_structs.h), [`http_server_handlers_map2.h`](https://github.com/monero-project/monero/blob/caa62bc9ea1c5f2ffe3ffa440ad230e1de509bfd/contrib/epee/include/net/http_server_handlers_map2.h) | JSON-RPC 2.0 implementation | `monerod`'s JSON-RPC 2.0 handling is spread across a few files. The first defines some data structures, the second contains macros that (essentially) implement JSON-RPC 2.0.
| [`cuprate-rpc-types`](https://doc.cuprate.org/cuprate_rpc_types) | [`core_rpc_server_commands_defs.h`](https://github.com/monero-project/monero/blob/caa62bc9ea1c5f2ffe3ffa440ad230e1de509bfd/src/rpc/core_rpc_server_commands_defs.h) | RPC request/response type definitions and (de)serialization | | | [`cuprate-rpc-types`](https://doc.cuprate.org/cuprate_rpc_types) | [`core_rpc_server_commands_defs.h`](https://github.com/monero-project/monero/blob/caa62bc9ea1c5f2ffe3ffa440ad230e1de509bfd/src/rpc/core_rpc_server_commands_defs.h) | RPC request/response type definitions and (de)serialization | |
| [`cuprate-rpc-interface`](https://doc.cuprate.org/cuprate_rpc_interface) | [`core_rpc_server.h`](https://github.com/monero-project/monero/blob/caa62bc9ea1c5f2ffe3ffa440ad230e1de509bfd/src/rpc/core_rpc_server.h) | RPC interface, routing, endpoints | | | [`cuprate-rpc-interface`](https://doc.cuprate.org/cuprate_rpc_interface) | [`core_rpc_server.h`](https://github.com/monero-project/monero/blob/caa62bc9ea1c5f2ffe3ffa440ad230e1de509bfd/src/rpc/core_rpc_server.h) | RPC interface, routing, endpoints | |
| [`cuprate-rpc-handler`](https://doc.cuprate.org/cuprate_rpc_handler) | [`core_rpc_server.cpp`](https://github.com/monero-project/monero/blob/caa62bc9ea1c5f2ffe3ffa440ad230e1de509bfd/src/rpc/core_rpc_server.cpp) | RPC request/response handling | These are the "inner handler" functions that turn requests into responses |
`cuprated` utilizes these crates and contains the actual functions that handle the request -> response mappings.
## Diagram
A diagram of the crate's responsibilities in `cuprated`'s RPC system.
```
cuprate-rpc-types
+
cuprate-json-rpc
+
cuprate-rpc-interface
│ │
┌───────────────────────────┤ ├───────────────────┐
▼ ▼ ▼ ▼
CLIENT ─► ROUTE ─► REQUEST ─► HANDLER ─► RESPONSE ─► CLIENT
▲ ▲
└───┬───┘
cuprated's handler functions
```
`cuprated` only contains the:
- handler functions (the functions that map requests into responses)
- glue code with the rest of Cuprate to make the above happen
All the other details are handled in other crates.

View file

@ -21,7 +21,7 @@ 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. 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; The main handler used by Cuprate is implemented in `cuprated` itself,
it implements the standard RPC handlers modeled after `monerod`. it implements the standard RPC handlers modeled after `monerod`.
# Purpose # Purpose