mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 12:48:00 +00:00
babe: replace usage of SharedEpochChanges with internal RPC (#13883)
* babe: replace usage of SharedEpochChanges with internal RPC * babe-rpc: fix tests * babe: use SinkExt::send instead of Sender::try_send SinkExt::send provides backpressure in case the channel is full * Update client/consensus/babe/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * babe: fix spawn * babe: send handles backpressure * babe: use testing::TaskExecutor * babe-rpc: better error handling --------- Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
@@ -203,7 +203,7 @@ pub fn new_partial(
|
||||
)?;
|
||||
|
||||
let slot_duration = babe_link.config().slot_duration();
|
||||
let import_queue = sc_consensus_babe::import_queue(
|
||||
let (import_queue, babe_worker_handle) = sc_consensus_babe::import_queue(
|
||||
babe_link.clone(),
|
||||
block_import.clone(),
|
||||
Some(Box::new(justification_import)),
|
||||
@@ -228,7 +228,7 @@ pub fn new_partial(
|
||||
let import_setup = (block_import, grandpa_link, babe_link);
|
||||
|
||||
let (rpc_extensions_builder, rpc_setup) = {
|
||||
let (_, grandpa_link, babe_link) = &import_setup;
|
||||
let (_, grandpa_link, _) = &import_setup;
|
||||
|
||||
let justification_stream = grandpa_link.justification_stream();
|
||||
let shared_authority_set = grandpa_link.shared_authority_set().clone();
|
||||
@@ -240,9 +240,6 @@ pub fn new_partial(
|
||||
Some(shared_authority_set.clone()),
|
||||
);
|
||||
|
||||
let babe_config = babe_link.config().clone();
|
||||
let shared_epoch_changes = babe_link.epoch_changes().clone();
|
||||
|
||||
let client = client.clone();
|
||||
let pool = transaction_pool.clone();
|
||||
let select_chain = select_chain.clone();
|
||||
@@ -258,9 +255,8 @@ pub fn new_partial(
|
||||
chain_spec: chain_spec.cloned_box(),
|
||||
deny_unsafe,
|
||||
babe: node_rpc::BabeDeps {
|
||||
babe_config: babe_config.clone(),
|
||||
shared_epoch_changes: shared_epoch_changes.clone(),
|
||||
keystore: keystore.clone(),
|
||||
babe_worker_handle: babe_worker_handle.clone(),
|
||||
},
|
||||
grandpa: node_rpc::GrandpaDeps {
|
||||
shared_voter_state: shared_voter_state.clone(),
|
||||
|
||||
@@ -21,7 +21,6 @@ sc-chain-spec = { version = "4.0.0-dev", path = "../../../client/chain-spec" }
|
||||
sc-client-api = { version = "4.0.0-dev", path = "../../../client/api" }
|
||||
sc-consensus-babe = { version = "0.10.0-dev", path = "../../../client/consensus/babe" }
|
||||
sc-consensus-babe-rpc = { version = "0.10.0-dev", path = "../../../client/consensus/babe/rpc" }
|
||||
sc-consensus-epochs = { version = "0.10.0-dev", path = "../../../client/consensus/epochs" }
|
||||
sc-consensus-grandpa = { version = "0.10.0-dev", path = "../../../client/consensus/grandpa" }
|
||||
sc-consensus-grandpa-rpc = { version = "0.10.0-dev", path = "../../../client/consensus/grandpa/rpc" }
|
||||
sc-rpc = { version = "4.0.0-dev", path = "../../../client/rpc" }
|
||||
|
||||
@@ -36,8 +36,7 @@ use std::sync::Arc;
|
||||
use jsonrpsee::RpcModule;
|
||||
use node_primitives::{AccountId, Balance, Block, BlockNumber, Hash, Index};
|
||||
use sc_client_api::AuxStore;
|
||||
use sc_consensus_babe::{BabeConfiguration, Epoch};
|
||||
use sc_consensus_epochs::SharedEpochChanges;
|
||||
use sc_consensus_babe::BabeWorkerHandle;
|
||||
use sc_consensus_grandpa::{
|
||||
FinalityProofProvider, GrandpaJustificationStream, SharedAuthoritySet, SharedVoterState,
|
||||
};
|
||||
@@ -53,10 +52,8 @@ use sp_keystore::KeystorePtr;
|
||||
|
||||
/// Extra dependencies for BABE.
|
||||
pub struct BabeDeps {
|
||||
/// BABE protocol config.
|
||||
pub babe_config: BabeConfiguration,
|
||||
/// BABE pending epoch changes.
|
||||
pub shared_epoch_changes: SharedEpochChanges<Block, Epoch>,
|
||||
/// A handle to the BABE worker for issuing requests.
|
||||
pub babe_worker_handle: BabeWorkerHandle<Block>,
|
||||
/// The keystore that manages the keys of the node.
|
||||
pub keystore: KeystorePtr,
|
||||
}
|
||||
@@ -130,7 +127,7 @@ where
|
||||
let mut io = RpcModule::new(());
|
||||
let FullDeps { client, pool, select_chain, chain_spec, deny_unsafe, babe, grandpa } = deps;
|
||||
|
||||
let BabeDeps { keystore, babe_config, shared_epoch_changes } = babe;
|
||||
let BabeDeps { keystore, babe_worker_handle } = babe;
|
||||
let GrandpaDeps {
|
||||
shared_voter_state,
|
||||
shared_authority_set,
|
||||
@@ -151,15 +148,8 @@ where
|
||||
io.merge(Mmr::new(client.clone()).into_rpc())?;
|
||||
io.merge(TransactionPayment::new(client.clone()).into_rpc())?;
|
||||
io.merge(
|
||||
Babe::new(
|
||||
client.clone(),
|
||||
shared_epoch_changes.clone(),
|
||||
keystore,
|
||||
babe_config,
|
||||
select_chain,
|
||||
deny_unsafe,
|
||||
)
|
||||
.into_rpc(),
|
||||
Babe::new(client.clone(), babe_worker_handle.clone(), keystore, select_chain, deny_unsafe)
|
||||
.into_rpc(),
|
||||
)?;
|
||||
io.merge(
|
||||
Grandpa::new(
|
||||
@@ -173,7 +163,7 @@ where
|
||||
)?;
|
||||
|
||||
io.merge(
|
||||
SyncState::new(chain_spec, client.clone(), shared_authority_set, shared_epoch_changes)?
|
||||
SyncState::new(chain_spec, client.clone(), shared_authority_set, babe_worker_handle)?
|
||||
.into_rpc(),
|
||||
)?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user