Skip to content

Commit

Permalink
add todos for rpc refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
clangenb committed Oct 26, 2024
1 parent 876ffdd commit 477ed7f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core/direct-rpc-server/src/rpc_responder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ where
if do_watch {
// We just store back the initial response, which is the top hash.
// This was implemented before we added the `RpcSubscriptionUpdate`
// and should probably be refactored in the future.
// and should probably be refactored in the future, see #1624.
//
// But for now this is fine, as we only use it to track ongoing connections.
self.connection_registry.store(hash, connection_token, rpc_response);
Expand Down
12 changes: 8 additions & 4 deletions core/direct-rpc-server/src/rpc_watch_extractor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use codec::Decode;
use itp_rpc::{RpcResponse, RpcReturnValue};
use itp_types::DirectRequestStatus;
use itp_utils::FromHexPrefixed;
use log::info;
use log::debug;
use std::marker::PhantomData;

pub struct RpcWatchExtractor<Hash>
Expand Down Expand Up @@ -59,10 +59,14 @@ where
let rpc_return_value = match RpcReturnValue::from_hex(&rpc_response.result) {
Ok(return_value) => return_value,
Err(e) => {
// if the return value is a hash
// `author_submitAndWatchExtrinsic` does currently only return the top hash
// as the first subscription response in order to comply with JSON RPC 2.0.
//
// We support this for now with this hack here, but it should be properly
// refactored in #1624.
if let Ok(hash) = Self::Hash::from_hex(&rpc_response.result) {
// fixme: hack to support json rpc 2.0 spec without rpc-server refactor.
info!("Returning hash as connection token");
// fixme: fix hack in #1624.
debug!("returning hash as connection token: {hash:?}");
return Ok(Some(hash))
}

Expand Down

0 comments on commit 477ed7f

Please sign in to comment.