Split the service initialisation up into seperate functions (#6332)

* Seperate out the complexity in ServiceBuilder::build_common into seperate functions

* Fix line widths

* Move some functions to their respective crates
This commit is contained in:
Ashley
2020-06-16 15:50:21 +02:00
committed by GitHub
parent c44947bbcb
commit 761dbd7dcc
19 changed files with 452 additions and 330 deletions
+10 -2
View File
@@ -25,6 +25,7 @@ use sp_runtime::traits::{NumberFor, Block, SaturatedConversion, UniqueSaturatedI
use sp_transaction_pool::PoolStatus;
use sp_utils::metrics::register_globals;
use sc_client_api::ClientInfo;
use sc_network::config::Role;
use sysinfo::{self, ProcessExt, SystemExt};
@@ -260,10 +261,17 @@ impl MetricsService {
impl MetricsService {
pub fn with_prometheus(registry: &Registry, name: &str, version: &str, roles: u64)
pub fn with_prometheus(registry: &Registry, name: &str, version: &str, role: &Role)
-> Result<Self, PrometheusError>
{
PrometheusMetrics::setup(registry, name, version, roles).map(|p| {
let role_bits = match role {
Role::Full => 1u64,
Role::Light => 2u64,
Role::Sentry { .. } => 3u64,
Role::Authority { .. } => 4u64,
};
PrometheusMetrics::setup(registry, name, version, role_bits).map(|p| {
Self::inner_new(Some(p))
})
}