Skip to content

Commit

Permalink
unused params from rpc
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshOrndorff committed Apr 16, 2024
1 parent 0963bf9 commit a08af58
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 86 deletions.
37 changes: 8 additions & 29 deletions node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,20 @@

#![warn(missing_docs)]

use std::sync::Arc;

use jsonrpsee::RpcModule;
use sc_transaction_pool_api::TransactionPool;
use sp_api::ProvideRuntimeApi;
use sp_block_builder::BlockBuilder;
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
use tuxedo_core::types::OpaqueBlock as Block;

pub use sc_rpc_api::DenyUnsafe;

/// Full client dependencies.
pub struct FullDeps<C, P> {
/// The client instance to use.
pub client: Arc<C>,
/// Transaction pool instance.
pub pool: Arc<P>,
/// Whether to deny unsafe calls
pub deny_unsafe: DenyUnsafe,
pub struct FullDeps {
// As you add RPC methods, you will likely need to add components to
// fetch data from. It is common to find the client or tx pool here.
// You will also need to add generic params and trait bounds as required.
// See the upstream Substrate node template for more details.
}

/// Instantiate all full RPC extensions.
pub fn create_full<C, P>(
_deps: FullDeps<C, P>,
) -> Result<RpcModule<()>, Box<dyn std::error::Error + Send + Sync>>
where
C: ProvideRuntimeApi<Block>
+ HeaderBackend<Block>
+ HeaderMetadata<Block, Error = BlockChainError>
+ Send
+ Sync
+ 'static,
C::Api: BlockBuilder<Block>,
P: TransactionPool + 'static,
{
pub fn create_full(
_deps: FullDeps,
) -> Result<RpcModule<()>, Box<dyn std::error::Error + Send + Sync>> {
let module = RpcModule::new(());
// Extend this RPC with a custom API by using the following syntax.
// `YourRpcStruct` should have a reference to a client, which is needed
Expand Down
11 changes: 2 additions & 9 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,8 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
let prometheus_registry = config.prometheus_registry().cloned();

let rpc_extensions_builder = {
let client = client.clone();
let pool = transaction_pool.clone();

Box::new(move |deny_unsafe, _| {
let deps = rpc::FullDeps {
client: client.clone(),
pool: pool.clone(),
deny_unsafe,
};
Box::new(move |_deny_unsafe, _| {
let deps = rpc::FullDeps {};
rpc::create_full(deps).map_err(Into::into)
})
};
Expand Down
11 changes: 2 additions & 9 deletions parachain-node/src/dev_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,8 @@ pub fn new_dev(config: Configuration) -> Result<TaskManager, ServiceError> {
}

let rpc_builder = {
let client = client.clone();
let transaction_pool = transaction_pool.clone();

Box::new(move |deny_unsafe, _| {
let deps = crate::rpc::FullDeps {
client: client.clone(),
pool: transaction_pool.clone(),
deny_unsafe,
};
Box::new(move |_deny_unsafe, _| {
let deps = crate::rpc::FullDeps {};

crate::rpc::create_full(deps).map_err(Into::into)
})
Expand Down
38 changes: 9 additions & 29 deletions parachain-node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,23 @@

#![warn(missing_docs)]

use std::sync::Arc;

use jsonrpsee::RpcModule;
pub use sc_rpc::DenyUnsafe;
use sc_transaction_pool_api::TransactionPool;
use sp_api::ProvideRuntimeApi;
use sp_block_builder::BlockBuilder;
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
use tuxedo_core::types::OpaqueBlock as Block;

/// A type representing all RPC extensions.
pub type RpcExtension = jsonrpsee::RpcModule<()>;

/// Full client dependencies
pub struct FullDeps<C, P> {
/// The client instance to use.
pub client: Arc<C>,
/// Transaction pool instance.
pub pool: Arc<P>,
/// Whether to deny unsafe calls
pub deny_unsafe: DenyUnsafe,
/// Full client dependencies.
pub struct FullDeps {
// As you add RPC methods, you will likely need to add components to
// fetch data from. It is common to find the client or tx pool here.
// You will also need to add generic params and trait bounds as required.
// See the upstream parachain node template for more details.
}

/// Instantiate all RPC extensions.
pub fn create_full<C, P>(
_deps: FullDeps<C, P>,
) -> Result<RpcExtension, Box<dyn std::error::Error + Send + Sync>>
where
C: ProvideRuntimeApi<Block>
+ HeaderBackend<Block>
+ HeaderMetadata<Block, Error = BlockChainError>
+ Send
+ Sync
+ 'static,
C::Api: BlockBuilder<Block>,
P: TransactionPool + Sync + Send + 'static,
{
pub fn create_full(
_deps: FullDeps,
) -> Result<RpcExtension, Box<dyn std::error::Error + Send + Sync>> {
let module = RpcModule::new(());
// Extend this RPC with a custom API by using the following syntax.
// `YourRpcStruct` should have a reference to a client, which is needed
Expand Down
12 changes: 2 additions & 10 deletions parachain-node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,8 @@ async fn start_node_impl(
.await?;

let rpc_builder = {
let client = client.clone();
let transaction_pool = transaction_pool.clone();

Box::new(move |deny_unsafe, _| {
let deps = crate::rpc::FullDeps {
client: client.clone(),
pool: transaction_pool.clone(),
deny_unsafe,
};

Box::new(move |_deny_unsafe, _| {
let deps = crate::rpc::FullDeps {};
crate::rpc::create_full(deps).map_err(Into::into)
})
};
Expand Down

0 comments on commit a08af58

Please sign in to comment.