From 32dceee09270c7fdb88e86a6e37a89587b88ae7a Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Fri, 2 Feb 2024 15:00:16 +0100 Subject: [PATCH] Revert "fix `rpc_methods` return type (#1647)" (#1657) This reverts commit c71073b1ee7abcda5a151bd03361ad42e98e6002. --- full-node/src/json_rpc_service/requests_handler.rs | 6 +++--- lib/src/json_rpc/methods.rs | 14 ++++++++++++-- .../src/json_rpc_service/background/getters.rs | 6 +++--- wasm-node/CHANGELOG.md | 1 - 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/full-node/src/json_rpc_service/requests_handler.rs b/full-node/src/json_rpc_service/requests_handler.rs index d942e90b54..f39e134fb4 100644 --- a/full-node/src/json_rpc_service/requests_handler.rs +++ b/full-node/src/json_rpc_service/requests_handler.rs @@ -92,11 +92,11 @@ pub fn spawn_requests_handler(config: Config) { match receiver.next().await { Some(Message::Request(request)) => match request.request() { methods::MethodCall::rpc_methods {} => { - request.respond(methods::Response::rpc_methods(methods::RpcMethods( - methods::MethodCall::method_names() + request.respond(methods::Response::rpc_methods(methods::RpcMethods { + methods: methods::MethodCall::method_names() .map(|n| n.into()) .collect(), - ))); + })); } methods::MethodCall::chainSpec_v1_chainName {} => { diff --git a/lib/src/json_rpc/methods.rs b/lib/src/json_rpc/methods.rs index 8c43ca5757..a9c42bf702 100644 --- a/lib/src/json_rpc/methods.rs +++ b/lib/src/json_rpc/methods.rs @@ -949,7 +949,9 @@ pub struct HeaderDigest { } #[derive(Debug, Clone)] -pub struct RpcMethods(pub Vec); +pub struct RpcMethods { + pub methods: Vec, +} #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] #[serde(tag = "type")] @@ -1107,7 +1109,15 @@ impl serde::Serialize for RpcMethods { where S: serde::Serializer, { - self.0[..].serialize(serializer) + #[derive(serde::Serialize)] + struct SerdeRpcMethods<'a> { + methods: &'a [String], + } + + SerdeRpcMethods { + methods: &self.methods, + } + .serialize(serializer) } } diff --git a/light-base/src/json_rpc_service/background/getters.rs b/light-base/src/json_rpc_service/background/getters.rs index 4f20d02efc..45b171646a 100644 --- a/light-base/src/json_rpc_service/background/getters.rs +++ b/light-base/src/json_rpc_service/background/getters.rs @@ -77,11 +77,11 @@ impl Background { /// Handles a call to [`methods::MethodCall::rpc_methods`]. pub(super) async fn rpc_methods(self: &Arc, request: service::RequestProcess) { - request.respond(methods::Response::rpc_methods(methods::RpcMethods( - methods::MethodCall::method_names() + request.respond(methods::Response::rpc_methods(methods::RpcMethods { + methods: methods::MethodCall::method_names() .map(|n| n.into()) .collect(), - ))); + })); } /// Handles a call to [`methods::MethodCall::sudo_unstable_version`]. diff --git a/wasm-node/CHANGELOG.md b/wasm-node/CHANGELOG.md index ae11c98b67..28943af661 100644 --- a/wasm-node/CHANGELOG.md +++ b/wasm-node/CHANGELOG.md @@ -4,7 +4,6 @@ ### Fixed -- The `rpc_methods` JSON-RPC function now properly returns an array of strings. ([#1647](https://github.com/smol-dot/smoldot/pull/1647)) - The warp syncing process no longer repeats itself every 32 blocks, which was causing unnecessary bandwidth and CPU usage. ([#1656](https://github.com/smol-dot/smoldot/pull/1656)) ## 2.0.20 - 2024-01-30