forest
forest copied to clipboard
Refactor the RPC API
The current state
- Types are defined here, using a naming scheme: https://github.com/ChainSafe/forest/blob/d6c96279addda1aea800654d9c12b9f8b2ce08ee/src/rpc_api/mod.rs#L192-L206
- Logic is defined in a separate file: https://github.com/ChainSafe/forest/blob/b3057ba599d285b5306c9c636ef08facb1f2ea42/src/rpc/chain_api.rs#L25-L39
I'd think we need a tower-compatible API:
pub trait RPCMethod<Ctx> {
type Params: HasLotusJson;
type Return: HasLotusJson;
(async?) fn call(&mut self, ctx: Ctx, params: Self::Params) -> Result<Self::Return, RPCError>;
}
We can then layer things like rate limiting, permissions, etc
Partially implemented in #3625
#4038 #4067