Skip to content
Snippets Groups Projects

Fix #250

Merged Benjamin Gallois requested to merge fix-250 into master
1 unresolved thread

Files

+ 47
4
@@ -23,9 +23,13 @@
@@ -23,9 +23,13 @@
pub use sc_rpc_api::DenyUnsafe;
pub use sc_rpc_api::DenyUnsafe;
use common_runtime::{AccountId, Balance, Block, Index};
use common_runtime::{AccountId, Balance, Block, BlockNumber, Hash, Index};
use jsonrpsee::RpcModule;
use jsonrpsee::RpcModule;
use sc_consensus_babe::{BabeApi, BabeWorkerHandle};
use sc_consensus_babe::{BabeApi, BabeWorkerHandle};
 
use sc_consensus_grandpa::{
 
self, FinalityProofProvider, GrandpaJustificationStream, SharedAuthoritySet, SharedVoterState,
 
};
 
use sc_rpc::SubscriptionTaskExecutor;
use sc_transaction_pool_api::TransactionPool;
use sc_transaction_pool_api::TransactionPool;
use sp_api::ProvideRuntimeApi;
use sp_api::ProvideRuntimeApi;
use sp_block_builder::BlockBuilder;
use sp_block_builder::BlockBuilder;
@@ -43,8 +47,23 @@ pub struct BabeDeps {
@@ -43,8 +47,23 @@ pub struct BabeDeps {
pub keystore: KeystorePtr,
pub keystore: KeystorePtr,
}
}
 
/// Dependencies for GRANDPA
 
#[derive(Clone)]
 
pub struct GrandpaDeps<B> {
 
/// Voting round info.
 
pub shared_voter_state: SharedVoterState,
 
/// Authority set info.
 
pub shared_authority_set: SharedAuthoritySet<Hash, BlockNumber>,
 
/// Receives notifications about justification events from Grandpa.
 
pub justification_stream: GrandpaJustificationStream<Block>,
 
/// Executor to drive the subscription manager in the Grandpa RPC handler.
 
pub subscription_executor: SubscriptionTaskExecutor,
 
/// Finality proof provider.
 
pub finality_provider: Arc<FinalityProofProvider<B, Block>>,
 
}
 
/// Full client dependencies.
/// Full client dependencies.
pub struct FullDeps<C, P, SC> {
pub struct FullDeps<C, P, SC, B> {
/// The client instance to use.
/// The client instance to use.
pub client: Arc<C>,
pub client: Arc<C>,
/// Transaction pool instance.
/// Transaction pool instance.
@@ -59,11 +78,13 @@ pub struct FullDeps<C, P, SC> {
@@ -59,11 +78,13 @@ pub struct FullDeps<C, P, SC> {
>,
>,
/// BABE specific dependencies.
/// BABE specific dependencies.
pub babe: Option<BabeDeps>,
pub babe: Option<BabeDeps>,
 
/// GRANDPA specific dependencies.
 
pub grandpa: GrandpaDeps<B>,
}
}
/// Instantiate all full RPC extensions.
/// Instantiate all full RPC extensions.
pub fn create_full<C, P, SC>(
pub fn create_full<C, P, SC, B>(
deps: FullDeps<C, P, SC>,
deps: FullDeps<C, P, SC, B>,
) -> Result<RpcModule<()>, Box<dyn std::error::Error + Send + Sync>>
) -> Result<RpcModule<()>, Box<dyn std::error::Error + Send + Sync>>
where
where
C: ProvideRuntimeApi<Block>,
C: ProvideRuntimeApi<Block>,
@@ -75,9 +96,11 @@ where
@@ -75,9 +96,11 @@ where
C::Api: BlockBuilder<Block>,
C::Api: BlockBuilder<Block>,
P: TransactionPool + 'static,
P: TransactionPool + 'static,
SC: SelectChain<Block> + 'static,
SC: SelectChain<Block> + 'static,
 
B: sc_client_api::Backend<Block> + 'static,
{
{
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
use sc_consensus_babe_rpc::{Babe, BabeApiServer};
use sc_consensus_babe_rpc::{Babe, BabeApiServer};
 
use sc_consensus_grandpa_rpc::{Grandpa, GrandpaApiServer};
use sc_consensus_manual_seal::rpc::{ManualSeal, ManualSealApiServer};
use sc_consensus_manual_seal::rpc::{ManualSeal, ManualSealApiServer};
use substrate_frame_rpc_system::{System, SystemApiServer};
use substrate_frame_rpc_system::{System, SystemApiServer};
@@ -89,6 +112,7 @@ where
@@ -89,6 +112,7 @@ where
deny_unsafe,
deny_unsafe,
command_sink_opt,
command_sink_opt,
babe,
babe,
 
grandpa,
} = deps;
} = deps;
if let Some(babe) = babe {
if let Some(babe) = babe {
@@ -107,6 +131,25 @@ where
@@ -107,6 +131,25 @@ where
.into_rpc(),
.into_rpc(),
)?;
)?;
}
}
 
 
let GrandpaDeps {
 
shared_voter_state,
 
shared_authority_set,
 
justification_stream,
 
subscription_executor,
 
finality_provider,
 
} = grandpa;
 
module.merge(
 
Grandpa::new(
 
subscription_executor,
 
shared_authority_set,
 
shared_voter_state,
 
justification_stream,
 
finality_provider,
 
)
 
.into_rpc(),
 
)?;
 
module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?;
module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?;
module.merge(TransactionPayment::new(client).into_rpc())?;
module.merge(TransactionPayment::new(client).into_rpc())?;
if let Some(command_sink) = command_sink_opt {
if let Some(command_sink) = command_sink_opt {
Loading