Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Companion PR for #5732
Add subscription RPC for listening on GRANDPA justifications.
  • Loading branch information
octol committed Jul 3, 2020
commit cabc8515e7de6e5890cb67f68bf58e08d6bfce58
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ macro_rules! new_full_start {
let grandpa_link = import_setup.as_ref().map(|s| &s.1)
.expect("GRANDPA LinkHalf is present for full services or set up failed; qed.");

let justification_receiver = grandpa_link.justification_receiver();
let shared_authority_set = grandpa_link.shared_authority_set().clone();
let shared_voter_state = grandpa::SharedVoterState::empty();

Expand All @@ -242,7 +243,7 @@ macro_rules! new_full_start {
.expect("SelectChain is present for full services or set up failed; qed.");
let keystore = builder.keystore().clone();

Ok(move |deny_unsafe| -> polkadot_rpc::RpcExtension {
Ok(move |deny_unsafe, subscriptions| -> polkadot_rpc::RpcExtension {
let deps = polkadot_rpc::FullDeps {
client: client.clone(),
pool: pool.clone(),
Expand All @@ -256,6 +257,8 @@ macro_rules! new_full_start {
grandpa: polkadot_rpc::GrandpaDeps {
shared_voter_state: shared_voter_state.clone(),
shared_authority_set: shared_authority_set.clone(),
justification_receiver: justification_receiver.clone(),
subscriptions,
},
};

Expand Down
1 change: 1 addition & 0 deletions rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition = "2018"

[dependencies]
jsonrpc-core = "14.0.3"
jsonrpc-pubsub = "14.0.3"
polkadot-primitives = { path = "../primitives" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down
8 changes: 8 additions & 0 deletions rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ pub struct GrandpaDeps {
pub shared_voter_state: sc_finality_grandpa::SharedVoterState,
/// Authority set info.
pub shared_authority_set: sc_finality_grandpa::SharedAuthoritySet<Hash, BlockNumber>,
/// Receives notifications about justification events from Grandpa.
pub justification_receiver: sc_finality_grandpa::GrandpaJustifications<Block>,
/// Subscription manager to keep track of pubsub subscribers.
pub subscriptions: jsonrpc_pubsub::manager::SubscriptionManager,
}

/// Full client dependencies
Expand Down Expand Up @@ -115,6 +119,8 @@ pub fn create_full<C, P, UE, SC>(deps: FullDeps<C, P, SC>) -> RpcExtension where
let GrandpaDeps {
shared_voter_state,
shared_authority_set,
justification_receiver,
subscriptions,
} = grandpa;

io.extend_with(
Expand All @@ -139,6 +145,8 @@ pub fn create_full<C, P, UE, SC>(deps: FullDeps<C, P, SC>) -> RpcExtension where
GrandpaApi::to_delegate(GrandpaRpcHandler::new(
shared_authority_set,
shared_voter_state,
justification_receiver,
subscriptions,
))
);
io
Expand Down
5 changes: 4 additions & 1 deletion service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ macro_rules! new_full_start {
let grandpa_link = import_setup.as_ref().map(|s| &s.1)
.expect("GRANDPA LinkHalf is present for full services or set up failed; qed.");

let justification_receiver = grandpa_link.justification_receiver();
let shared_authority_set = grandpa_link.shared_authority_set().clone();
let shared_voter_state = grandpa::SharedVoterState::empty();

Expand All @@ -238,7 +239,7 @@ macro_rules! new_full_start {
.expect("SelectChain is present for full services or set up failed; qed.");
let keystore = builder.keystore().clone();

Ok(move |deny_unsafe| -> polkadot_rpc::RpcExtension {
Ok(move |deny_unsafe, subscriptions| -> polkadot_rpc::RpcExtension {
let deps = polkadot_rpc::FullDeps {
client: client.clone(),
pool: pool.clone(),
Expand All @@ -252,6 +253,8 @@ macro_rules! new_full_start {
grandpa: polkadot_rpc::GrandpaDeps {
shared_voter_state: shared_voter_state.clone(),
shared_authority_set: shared_authority_set.clone(),
justification_receiver: justification_receiver.clone(),
subscriptions,
},
};

Expand Down