Add the ability to change the informant's prefix (#1221)

* Initial commit

Forked at: 261d701c5b
Parent branch: origin/master

* Add the ability to change the informant's prefix

* Update Cargo.lock

* Update Cargo.lock

* fixed tests

* Rename prefix to informant prefix
This commit is contained in:
Cecile Tonglet
2020-06-10 16:50:47 +02:00
committed by GitHub
parent 67e7fba60d
commit 61e82c3495
4 changed files with 28 additions and 12 deletions
+15 -7
View File
@@ -149,7 +149,7 @@ fn set_prometheus_registry(config: &mut Configuration) -> Result<(), ServiceErro
/// Use this macro if you don't actually need the full service, but just the builder in order to
/// be able to perform chain operations.
macro_rules! new_full_start {
($config:expr, $runtime:ty, $executor:ty) => {{
($config:expr, $runtime:ty, $executor:ty, $informant_prefix:expr $(,)?) => {{
set_prometheus_registry(&mut $config)?;
let mut import_setup = None;
@@ -158,6 +158,7 @@ macro_rules! new_full_start {
let builder = service::ServiceBuilder::new_full::<
Block, $runtime, $executor
>($config)?
.with_informant_prefix($informant_prefix.unwrap_or_default())?
.with_select_chain(|_, backend| {
Ok(sc_consensus::LongestChain::new(backend.clone()))
})?
@@ -274,7 +275,8 @@ macro_rules! new_full {
$slot_duration:expr,
$grandpa_pause:expr,
$runtime:ty,
$dispatch:ty
$dispatch:ty,
$informant_prefix:expr $(,)?
) => {{
use sc_network::Event;
use sc_client_api::ExecutorProvider;
@@ -296,7 +298,7 @@ macro_rules! new_full {
let slot_duration = $slot_duration;
let (builder, mut import_setup, inherent_data_providers, mut rpc_setup) =
new_full_start!($config, $runtime, $dispatch);
new_full_start!($config, $runtime, $dispatch, $informant_prefix);
let service = builder
.with_finality_proof_provider(|client, backend| {
@@ -647,7 +649,7 @@ where
<Runtime::RuntimeApi as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<BlakeTwo256>,
{
config.keystore = service::config::KeystoreConfig::InMemory;
Ok(new_full_start!(config, Runtime, Dispatch).0)
Ok(new_full_start!(config, Runtime, Dispatch, None).0)
}
/// Create a new Polkadot service for a full node.
@@ -659,6 +661,7 @@ pub fn polkadot_new_full(
authority_discovery_enabled: bool,
slot_duration: u64,
grandpa_pause: Option<(u32, u32)>,
informant_prefix: Option<String>,
)
-> Result<(
impl AbstractService,
@@ -678,7 +681,8 @@ pub fn polkadot_new_full(
slot_duration,
grandpa_pause,
polkadot_runtime::RuntimeApi,
PolkadotExecutor
PolkadotExecutor,
informant_prefix,
);
Ok((service, client, handles))
@@ -693,6 +697,7 @@ pub fn kusama_new_full(
authority_discovery_enabled: bool,
slot_duration: u64,
grandpa_pause: Option<(u32, u32)>,
informant_prefix: Option<String>,
) -> Result<(
impl AbstractService,
Arc<impl PolkadotClient<
@@ -712,7 +717,8 @@ pub fn kusama_new_full(
slot_duration,
grandpa_pause,
kusama_runtime::RuntimeApi,
KusamaExecutor
KusamaExecutor,
informant_prefix,
);
Ok((service, client, handles))
@@ -727,6 +733,7 @@ pub fn westend_new_full(
authority_discovery_enabled: bool,
slot_duration: u64,
grandpa_pause: Option<(u32, u32)>,
informant_prefix: Option<String>,
)
-> Result<(
impl AbstractService,
@@ -746,7 +753,8 @@ pub fn westend_new_full(
slot_duration,
grandpa_pause,
westend_runtime::RuntimeApi,
WestendExecutor
WestendExecutor,
informant_prefix,
);
Ok((service, client, handles))