Skip to content

Conversation

hinto-janai
Copy link
Contributor

What

This adds some types/traits to cuprate_rpc_types.

This adds 6 enums for encapsulating RPC requests/responses:

  • crate::json::JsonRpcRequest & crate::json::JsonRpcResponse
  • crate::bin::BinRequest & crate::bin::BinResponse
  • crate::other::OtherRequest & crate::other::OtherResponse

2 traits that contains some metadata about RPC request/responses:

  • RpcCall
  • RpcCallValue

and changes to the type generator macro to auto implement the traits.

Why

Both enum types and metadata is needed for actual RPC usage: #233.

How

See below review.

@github-actions github-actions bot added A-docs Area: Related to documentation. A-rpc Area: Related to RPC. labels Aug 1, 2024
Comment on lines +1572 to +1586
/// JSON-RPC requests.
///
/// This enum contains all [`crate::json`] requests.
///
/// See also: [`JsonRpcResponse`].
///
/// TODO: document and test (de)serialization behavior after figuring out `method/params`.
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[cfg_attr(
feature = "serde",
serde(rename_all = "snake_case", tag = "method", content = "params")
)]
#[allow(missing_docs)]
pub enum JsonRpcRequest {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: this is the problematic method/params enum btw. Will fix in another PR.

@hinto-janai hinto-janai marked this pull request as ready for review August 1, 2024 00:36
@hinto-janai hinto-janai requested a review from Boog900 August 1, 2024 00:36
@hinto-janai hinto-janai changed the title rpc: add traits and enum requests/responses rpc-types: add traits and enum requests/responses Aug 1, 2024
Comment on lines +1560 to +1561
GetTxIdsLoose,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to be an annoying endpoint to support, it may require DB changes, depending on what guarantees we need to make

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably be ok dropping support for this end point.

@Boog900 Boog900 merged commit bd375ea into Cuprate:main Aug 1, 2024
@hinto-janai hinto-janai mentioned this pull request Aug 1, 2024
25 tasks
@hinto-janai hinto-janai deleted the types branch August 1, 2024 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: Related to documentation. A-rpc Area: Related to RPC.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants