Skip to content

Commit b5a0708

Browse files
authored
rpc/client: Propagate rpc_methods method to reported methods (#1713)
The PR exposes the `rpc_methods` name in the `rpc_methods` response. This feature is useful for servers that only forward requests to methods that are reported by the `rpc_methods`. Jsonrpsee exposes the available methods registered so far. Registering the `rpc_methods` requires a closure that already stores the result. As such, the `rpc_methods` method name is manually added to the available methods. Closes: #1627 ### Testing Done ``` $> curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "rpc_methods", "params":[]}' http://localhost:9944 {"jsonrpc":"2.0","result":{"methods":["account_nextIndex",... "rpc_methods",..."unsubscribe_newHead"]},"id":1}⏎ ``` @paritytech/subxt-team --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
1 parent 50242a6 commit b5a0708

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

  • substrate/client/rpc-servers/src

substrate/client/rpc-servers/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ fn hosts_filtering(enabled: bool, addrs: &[SocketAddr]) -> AllowHosts {
145145

146146
fn build_rpc_api<M: Send + Sync + 'static>(mut rpc_api: RpcModule<M>) -> RpcModule<M> {
147147
let mut available_methods = rpc_api.method_names().collect::<Vec<_>>();
148+
// The "rpc_methods" is defined below and we want it to be part of the reported methods.
149+
available_methods.push("rpc_methods");
148150
available_methods.sort();
149151

150152
rpc_api

0 commit comments

Comments
 (0)