Skip to content
Snippets Groups Projects
Commit 96006322 authored by Niklas Adolfsson's avatar Niklas Adolfsson Committed by GitHub
Browse files

fix: regression of `sync_state_genSyncSpec` #11435 (#11437)

* fix: #11435

* address grumbles: better safe than sorry
parent 32d6d1b3
Branches
No related merge requests found
...@@ -128,7 +128,7 @@ pub struct LightSyncState<Block: BlockT> { ...@@ -128,7 +128,7 @@ pub struct LightSyncState<Block: BlockT> {
pub trait SyncStateRpcApi { pub trait SyncStateRpcApi {
/// Returns the JSON serialized chainspec running the node, with a sync state. /// Returns the JSON serialized chainspec running the node, with a sync state.
#[method(name = "sync_state_genSyncSpec")] #[method(name = "sync_state_genSyncSpec")]
fn system_gen_sync_spec(&self, raw: bool) -> RpcResult<String>; fn system_gen_sync_spec(&self, raw: bool) -> RpcResult<serde_json::Value>;
} }
/// An api for sync state RPC calls. /// An api for sync state RPC calls.
...@@ -185,7 +185,7 @@ where ...@@ -185,7 +185,7 @@ where
Block: BlockT, Block: BlockT,
Backend: HeaderBackend<Block> + sc_client_api::AuxStore + 'static, Backend: HeaderBackend<Block> + sc_client_api::AuxStore + 'static,
{ {
fn system_gen_sync_spec(&self, raw: bool) -> RpcResult<String> { fn system_gen_sync_spec(&self, raw: bool) -> RpcResult<serde_json::Value> {
let current_sync_state = self.build_sync_state()?; let current_sync_state = self.build_sync_state()?;
let mut chain_spec = self.chain_spec.cloned_box(); let mut chain_spec = self.chain_spec.cloned_box();
...@@ -197,6 +197,7 @@ where ...@@ -197,6 +197,7 @@ where
let val = serde_json::to_value(&current_sync_state)?; let val = serde_json::to_value(&current_sync_state)?;
*extension = Some(val); *extension = Some(val);
chain_spec.as_json(raw).map_err(|e| Error::<Block>::JsonRpc(e).into()) let json_str = chain_spec.as_json(raw).map_err(|e| Error::<Block>::JsonRpc(e))?;
serde_json::from_str(&json_str).map_err(Into::into)
} }
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment