@@ -9,6 +9,7 @@ use std::sync::Arc;
99
1010use jsonrpsee:: RpcModule ;
1111use polkadot_bulletin_chain_runtime:: { opaque:: Block , AccountId , BlockNumber , Hash , Nonce } ;
12+ use sc_consensus_babe:: { BabeApi , BabeWorkerHandle } ;
1213use sc_consensus_grandpa:: {
1314 FinalityProofProvider , GrandpaJustificationStream , SharedAuthoritySet , SharedVoterState ,
1415} ;
@@ -18,17 +19,31 @@ use sc_transaction_pool_api::TransactionPool;
1819use sp_api:: ProvideRuntimeApi ;
1920use sp_block_builder:: BlockBuilder ;
2021use sp_blockchain:: { Error as BlockChainError , HeaderBackend , HeaderMetadata } ;
22+ use sp_consensus:: SelectChain ;
23+ use sp_keystore:: KeystorePtr ;
2124
2225/// Full client dependencies.
23- pub struct FullDeps < C , P , B > {
26+ pub struct FullDeps < C , P , SC , B > {
2427 /// The client instance to use.
2528 pub client : Arc < C > ,
2629 /// Transaction pool instance.
2730 pub pool : Arc < P > ,
31+ /// The chain selection strategy.
32+ pub select_chain : SC ,
33+ /// BABE RPC dependencies.
34+ pub babe : BabeDeps ,
2835 /// GRANDPA RPC dependencies.
2936 pub grandpa : GrandpaDeps < B > ,
3037}
3138
39+ /// BABE RPC dependencies.
40+ pub struct BabeDeps {
41+ /// A handle to the BABE worker for issuing requests.
42+ pub babe_worker_handle : BabeWorkerHandle < Block > ,
43+ /// The keystore that manages the keys of the node.
44+ pub keystore : KeystorePtr ,
45+ }
46+
3247/// GRANDPA RPC dependncies.
3348pub struct GrandpaDeps < B > {
3449 /// Subscription task executor.
@@ -44,24 +59,30 @@ pub struct GrandpaDeps<B> {
4459}
4560
4661/// Instantiate all full RPC extensions.
47- pub fn create_full < C , P , B > (
48- deps : FullDeps < C , P , B > ,
62+ pub fn create_full < C , P , SC , B > (
63+ deps : FullDeps < C , P , SC , B > ,
4964) -> Result < RpcModule < ( ) > , Box < dyn std:: error:: Error + Send + Sync > >
5065where
5166 C : ProvideRuntimeApi < Block > ,
5267 C : HeaderBackend < Block > + HeaderMetadata < Block , Error = BlockChainError > + ' static ,
5368 C : Send + Sync + ' static ,
5469 C :: Api : substrate_frame_rpc_system:: AccountNonceApi < Block , AccountId , Nonce > ,
5570 C :: Api : BlockBuilder < Block > ,
71+ C :: Api : BabeApi < Block > ,
5672 P : TransactionPool + ' static ,
73+ SC : SelectChain < Block > + ' static ,
5774 B : sc_client_api:: Backend < Block > + Send + Sync + ' static ,
5875{
76+ use sc_consensus_babe_rpc:: { Babe , BabeApiServer } ;
5977 use substrate_frame_rpc_system:: { System , SystemApiServer } ;
6078
6179 let mut module = RpcModule :: new ( ( ) ) ;
62- let FullDeps { client, pool, grandpa } = deps;
80+ let FullDeps { client, pool, select_chain, babe, grandpa } = deps;
81+ let BabeDeps { babe_worker_handle, keystore } = babe;
6382
64- module. merge ( System :: new ( client, pool) . into_rpc ( ) ) ?;
83+ module. merge ( System :: new ( client. clone ( ) , pool) . into_rpc ( ) ) ?;
84+ module
85+ . merge ( Babe :: new ( client, babe_worker_handle. clone ( ) , keystore, select_chain) . into_rpc ( ) ) ?;
6586 module. merge (
6687 Grandpa :: new (
6788 grandpa. subscription_executor ,
0 commit comments