Unify rpc api and implementation name (#11469)

* Unify rpc api and implementation name

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* MauanlSeal ==> ManualSealRpc

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Remove extra Rpc naming in the structs

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Update doc

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* fix merge

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
Qinxuan Chen
2022-05-21 14:13:09 +08:00
committed by GitHub
parent dcb8a8504e
commit 5497069d54
12 changed files with 72 additions and 83 deletions
+9 -14
View File
@@ -100,17 +100,17 @@ pub trait BeefyApi<Notification, Hash> {
}
/// Implements the BeefyApi RPC trait for interacting with BEEFY.
pub struct BeefyRpcHandler<Block: BlockT> {
pub struct Beefy<Block: BlockT> {
signed_commitment_stream: BeefySignedCommitmentStream<Block>,
beefy_best_block: Arc<RwLock<Option<Block::Hash>>>,
executor: SubscriptionTaskExecutor,
}
impl<Block> BeefyRpcHandler<Block>
impl<Block> Beefy<Block>
where
Block: BlockT,
{
/// Creates a new BeefyRpcHandler instance.
/// Creates a new Beefy Rpc handler instance.
pub fn new(
signed_commitment_stream: BeefySignedCommitmentStream<Block>,
best_block_stream: BeefyBestBlockStream<Block>,
@@ -131,8 +131,7 @@ where
}
#[async_trait]
impl<Block> BeefyApiServer<notification::EncodedSignedCommitment, Block::Hash>
for BeefyRpcHandler<Block>
impl<Block> BeefyApiServer<notification::EncodedSignedCommitment, Block::Hash> for Beefy<Block>
where
Block: BlockT,
{
@@ -174,24 +173,20 @@ mod tests {
use sp_runtime::traits::{BlakeTwo256, Hash};
use substrate_test_runtime_client::runtime::Block;
fn setup_io_handler() -> (RpcModule<BeefyRpcHandler<Block>>, BeefySignedCommitmentSender<Block>)
{
fn setup_io_handler() -> (RpcModule<Beefy<Block>>, BeefySignedCommitmentSender<Block>) {
let (_, stream) = BeefyBestBlockStream::<Block>::channel();
setup_io_handler_with_best_block_stream(stream)
}
fn setup_io_handler_with_best_block_stream(
best_block_stream: BeefyBestBlockStream<Block>,
) -> (RpcModule<BeefyRpcHandler<Block>>, BeefySignedCommitmentSender<Block>) {
) -> (RpcModule<Beefy<Block>>, BeefySignedCommitmentSender<Block>) {
let (commitment_sender, commitment_stream) =
BeefySignedCommitmentStream::<Block>::channel();
let handler = BeefyRpcHandler::new(
commitment_stream,
best_block_stream,
sc_rpc::testing::test_executor(),
)
.expect("Setting up the BEEFY RPC handler works");
let handler =
Beefy::new(commitment_stream, best_block_stream, sc_rpc::testing::test_executor())
.expect("Setting up the BEEFY RPC handler works");
(handler.into_rpc(), commitment_sender)
}