Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
grandpa: collect grandpa rpc deps
Browse files Browse the repository at this point in the history
  • Loading branch information
octol committed Apr 15, 2020
1 parent 46f8b4a commit 8b11a5b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
6 changes: 4 additions & 2 deletions bin/node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ macro_rules! new_full_start {
babe_config: sc_consensus_babe::BabeLink::config(babe_link).clone(),
shared_epoch_changes: sc_consensus_babe::BabeLink::epoch_changes(babe_link).clone()
},
shared_voter_state: Arc::clone(&shared_voter_state),
shared_authority_set: shared_authority_set.clone(),
grandpa: node_rpc::GrandpaDeps {
shared_voter_state: Arc::clone(&shared_voter_state),
shared_authority_set: shared_authority_set.clone(),
}
};
Ok(node_rpc::create_full(deps))
})?;
Expand Down
21 changes: 15 additions & 6 deletions bin/node/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ pub struct BabeDeps {
pub keystore: KeyStorePtr,
}

/// Extra dependencies for GRANDPA
pub struct GrandpaDeps {
/// Voting round info.
pub shared_voter_state: SharedVoterState<AuthorityId>,
/// Authority set info.
pub shared_authority_set: SharedAuthoritySet<Hash, BlockNumber>,
}

/// Full client dependencies.
pub struct FullDeps<C, P, SC> {
/// The client instance to use.
Expand All @@ -77,10 +85,8 @@ pub struct FullDeps<C, P, SC> {
pub select_chain: SC,
/// BABE specific dependencies.
pub babe: BabeDeps,
/// Used to query the voter state in GRANDPA.
pub shared_voter_state: SharedVoterState<AuthorityId>,
/// WIP: add doc
pub shared_authority_set: SharedAuthoritySet<Hash, BlockNumber>,
/// GRANDPA specific dependencies.
pub grandpa: GrandpaDeps,
}

/// Instantiate all Full RPC extensions.
Expand Down Expand Up @@ -109,14 +115,17 @@ pub fn create_full<C, P, M, SC>(
pool,
select_chain,
babe,
shared_voter_state,
shared_authority_set,
grandpa,
} = deps;
let BabeDeps {
keystore,
babe_config,
shared_epoch_changes,
} = babe;
let GrandpaDeps {
shared_voter_state,
shared_authority_set,
} = grandpa;

io.extend_with(
SystemApi::to_delegate(FullSystem::new(client.clone(), pool))
Expand Down

0 comments on commit 8b11a5b

Please sign in to comment.