Skip to content

Commit

Permalink
archive: Remove unsued backend and task executor
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
  • Loading branch information
lexnv committed Sep 15, 2023
1 parent 9ecf0c6 commit fa041a3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 24 deletions.
23 changes: 4 additions & 19 deletions substrate/client/rpc-spec-v2/src/archive/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//! API implementation for `archive`.

use super::ArchiveApiServer;
use crate::{chain_head::hex_string, SubscriptionTaskExecutor};
use crate::chain_head::hex_string;
use codec::Encode;
use jsonrpsee::core::{async_trait, RpcResult};
use sc_client_api::{Backend, BlockBackend, BlockchainEvents, ExecutorProvider, StorageProvider};
Expand All @@ -32,32 +32,17 @@ use std::{marker::PhantomData, sync::Arc};
pub struct Archive<BE: Backend<Block>, Block: BlockT, Client> {
/// Substrate client.
client: Arc<Client>,
/// Backend of the chain.
_backend: Arc<BE>,
/// Executor to spawn subscriptions.
_executor: SubscriptionTaskExecutor,
/// The hexadecimal encoded hash of the genesis block.
genesis_hash: String,
/// Phantom member to pin the block type.
_phantom: PhantomData<Block>,
_phantom: PhantomData<(Block, BE)>,
}

impl<BE: Backend<Block>, Block: BlockT, Client> Archive<BE, Block, Client> {
/// Create a new [`Archive`].
pub fn new<GenesisHash: AsRef<[u8]>>(
client: Arc<Client>,
backend: Arc<BE>,
executor: SubscriptionTaskExecutor,
genesis_hash: GenesisHash,
) -> Self {
pub fn new<GenesisHash: AsRef<[u8]>>(client: Arc<Client>, genesis_hash: GenesisHash) -> Self {
let genesis_hash = hex_string(&genesis_hash.as_ref());
Self {
client,
_backend: backend.clone(),
_executor: executor,
genesis_hash,
_phantom: PhantomData,
}
Self { client, genesis_hash, _phantom: PhantomData }
}
}

Expand Down
6 changes: 1 addition & 5 deletions substrate/client/rpc-spec-v2/src/archive/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use jsonrpsee::{types::EmptyServerParams as EmptyParams, RpcModule};
use sc_block_builder::BlockBuilderProvider;

use sp_consensus::BlockOrigin;
use sp_core::testing::TaskExecutor;
use std::sync::Arc;
use substrate_test_runtime_client::{
prelude::*, runtime, Backend, BlockBuilderExt, Client, ClientBlockImportExt,
Expand All @@ -39,12 +38,9 @@ type Block = substrate_test_runtime_client::runtime::Block;

fn setup_api() -> (Arc<Client<Backend>>, RpcModule<Archive<Backend, Block, Client<Backend>>>) {
let builder = TestClientBuilder::new();
let backend = builder.backend();
let client = Arc::new(builder.build());

let api =
Archive::new(client.clone(), backend, Arc::new(TaskExecutor::default()), CHAIN_GENESIS)
.into_rpc();
let api = Archive::new(client.clone(), CHAIN_GENESIS).into_rpc();

(client, api)
}
Expand Down

0 comments on commit fa041a3

Please sign in to comment.