Skip to content

Commit

Permalink
build dev consensus
Browse files Browse the repository at this point in the history
Signed-off-by: zqhxuyuan <zqhxuyuan@gmail.com>
  • Loading branch information
zqhxuyuan committed Jan 5, 2023
1 parent b1fb567 commit a998def
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
15 changes: 5 additions & 10 deletions node/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use crate::{
instant_finalize::InstantFinalizeBlockImport,
service::{Client, StateBackend, TransactionPool},
};
use std::future::Future;

pub use manta_primitives::types::{AccountId, Balance, Block, Hash, Header, Index as Nonce};
use polkadot_service::CollatorPair;
Expand Down Expand Up @@ -144,14 +145,14 @@ where
}))
}

/// start standalone dev consensus
pub fn start_dev_nimbus_instant_seal_consensus<RuntimeApi>(
/// build standalone mode dev consensus using manual instant seal
pub fn build_dev_nimbus_consensus<RuntimeApi>(
client: Arc<Client<RuntimeApi>>,
transaction_pool: Arc<TransactionPool<RuntimeApi>>,
keystore_container: &KeystoreContainer,
select_chain: LongestChain<TFullBackend<Block>, Block>,
task_manager: &TaskManager,
) -> Result<(), Error>
) -> Result<impl Future<Output = ()> + Send + 'static, Error>
where
RuntimeApi: ConstructRuntimeApi<Block, Client<RuntimeApi>> + Send + Sync + 'static,
RuntimeApi::RuntimeApi: RuntimeApiCommon<StateBackend = StateBackend> + RuntimeApiNimbus,
Expand Down Expand Up @@ -225,11 +226,5 @@ where
},
});

task_manager.spawn_essential_handle().spawn_blocking(
"authorship_task",
Some("block-authoring"),
consensus,
);

Ok(())
Ok(consensus)
}
2 changes: 1 addition & 1 deletion node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ pub fn run_with(cli: Cli) -> Result {

runner.run_node_until_exit(|config| async move {
if is_dev {
info!("DEV STANDALONE MODE.");
info!("⚠️ DEV STANDALONE MODE.");
if config.chain_spec.is_dolphin() {
return crate::service::start_dev_nimbus_node::<dolphin_runtime::RuntimeApi, _>(
config,
Expand Down
8 changes: 7 additions & 1 deletion node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,13 +424,19 @@ where
let select_chain = LongestChain::new(backend.clone());

if role.is_authority() {
crate::builder::start_dev_nimbus_instant_seal_consensus(
let dev_consensus = crate::builder::build_dev_nimbus_consensus(
client.clone(),
transaction_pool.clone(),
&keystore_container,
select_chain,
&task_manager,
)?;

task_manager.spawn_essential_handle().spawn_blocking(
"authorship_task",
Some("block-authoring"),
dev_consensus,
);
}

let rpc_builder = {
Expand Down

0 comments on commit a998def

Please sign in to comment.