Trait cuprate_rpc_interface::RpcHandler

source ·
pub trait RpcHandler:
    RpcService<JsonRpcRequest, JsonRpcResponse>
    + RpcService<BinRequest, BinResponse>
    + RpcService<OtherRequest, OtherResponse> {
    // Required method
    fn restricted(&self) -> bool;
}
Expand description

An RPC handler.

This trait represents a type that can turn Requests into Responses.

Implementors of this trait must be:

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 anyhow::Error.

See this crate’s RpcHandlerDummy for an implementation example of this trait.

§Panics

Your RpcHandler must reply to Requests with the correct Response or else this crate will panic during routing functions.

For example, a JsonRpcRequest::GetBlockCount must be replied with JsonRpcResponse::GetBlockCount. If anything else is returned, this crate may panic.

Required Methods§

source

fn restricted(&self) -> bool

Is this RpcHandler restricted?

If this returns true, restricted methods and endpoints such as:

  • /json_rpc’s relay_tx method
  • The /pop_blocks endpoint

will automatically be denied access when using the axum::Router provided by RouterBuilder.

Object Safety§

This trait is not object safe.

Implementors§