Skip to content

Commit

Permalink
Revert "fix rpc_methods return type (#1647)" (#1657)
Browse files Browse the repository at this point in the history
This reverts commit c71073b.
  • Loading branch information
tomaka authored Feb 2, 2024
1 parent c0f75b8 commit 32dceee
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
6 changes: 3 additions & 3 deletions full-node/src/json_rpc_service/requests_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {} => {
Expand Down
14 changes: 12 additions & 2 deletions lib/src/json_rpc/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,9 @@ pub struct HeaderDigest {
}

#[derive(Debug, Clone)]
pub struct RpcMethods(pub Vec<String>);
pub struct RpcMethods {
pub methods: Vec<String>,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(tag = "type")]
Expand Down Expand Up @@ -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)
}
}

Expand Down
6 changes: 3 additions & 3 deletions light-base/src/json_rpc_service/background/getters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ impl<TPlat: PlatformRef> Background<TPlat> {

/// Handles a call to [`methods::MethodCall::rpc_methods`].
pub(super) async fn rpc_methods(self: &Arc<Self>, 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`].
Expand Down
1 change: 0 additions & 1 deletion wasm-node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 32dceee

Please sign in to comment.