The network configuration now makes more sense (#2706)

* The network configuration now makes more sense

* Reexport ProtocolConfig
This commit is contained in:
Pierre Krieger
2019-05-28 16:50:36 +02:00
committed by Gavin Wood
parent 3a0c52f2b1
commit f8303a6b57
5 changed files with 47 additions and 44 deletions
+16 -1
View File
@@ -34,7 +34,7 @@ use crate::on_demand::{OnDemandCore, OnDemandNetwork, RequestData};
use crate::specialization::NetworkSpecialization;
use crate::sync::{ChainSync, Context as SyncContext, Status as SyncStatus, SyncState};
use crate::service::{TransactionPool, ExHashT};
use crate::config::{ProtocolConfig, Roles};
use crate::config::Roles;
use rustc_hex::ToHex;
use std::collections::{BTreeMap, HashMap};
use std::sync::Arc;
@@ -273,6 +273,21 @@ struct ContextData<B: BlockT, H: ExHashT> {
pub chain: Arc<Client<B>>,
}
/// Configuration for the Substrate-specific part of the networking layer.
#[derive(Clone)]
pub struct ProtocolConfig {
/// Assigned roles.
pub roles: Roles,
}
impl Default for ProtocolConfig {
fn default() -> ProtocolConfig {
ProtocolConfig {
roles: Roles::FULL,
}
}
}
impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> Protocol<B, S, H> {
/// Create a new instance.
pub fn new(