ChainSafe / forest

🌲 Rust Filecoin Node Implementation
https://forest.chainsafe.io
Apache License 2.0
637 stars 157 forks source link

[tracking] RPC refactoring wishlist #4032

Open aatifsyed opened 8 months ago

aatifsyed commented 8 months ago

The motivating use-case is #4038. While we're in the area we can do a lot of cleanup.

aatifsyed commented 6 months ago

Code snippets file for VSCode:

// This should live somewhere like `${workspaceDir}/.vscode/rpc.code-snippets`
{
    "rpc method": {
        "prefix": "impl RpcMethod",
        "body": [
            "pub enum ${1:MethodName} {}",
            "impl RpcMethod<${2:ARITY}> for $1 {",
            "const NAME: &'static str = \"Filecoin.$1\";",
            "const PARAM_NAMES: [&'static str; $2] = [$3];",
            "const API_VERSION: ApiVersion = ApiVersion::${7:V0};",
            "",
            "type Params = ($4);",
            "type Ok = $6;",
            "",
            "async fn handle(ctx: Ctx<impl Blockstore $8>, ($5): Self::Params) -> Result<Self::Ok, ServerError> {",
            "$0",
            "}", // fn handle
            "}", // impl RpcMethod
        ]
    },
    "imports": {
        "prefix": "use",
        "body": [
            "use crate::rpc::{reflect::SelfDescribingRpcModule, ApiVersion, Ctx, RPCState, RpcMethod, RpcMethodExt as _, ServerError};",
            "use schemars::JsonSchema;"
        ]
    },
}