Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Change dev chain detection.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomusdrw committed Nov 5, 2018
1 parent b9d9e7d commit ec41b47
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
7 changes: 6 additions & 1 deletion parity/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,10 @@ impl Configuration {
Ok(name.parse()?)
}

fn is_dev_chain(&self) -> Result<bool, String> {
Ok(self.chain()? == SpecType::Dev)
}

fn max_peers(&self) -> u32 {
self.args.arg_max_peers
.or(cmp::max(self.args.arg_min_peers, Some(DEFAULT_MAX_PEERS)))
Expand Down Expand Up @@ -528,7 +532,7 @@ impl Configuration {
}

fn miner_options(&self) -> Result<MinerOptions, String> {
let is_dev_chain = self.chain()? == SpecType::Dev;
let is_dev_chain = self.is_dev_chain()?;
if is_dev_chain && self.args.flag_force_sealing && self.args.arg_reseal_min_period == 0 {
return Err("Force sealing can't be used with reseal_min_period = 0".into());
}
Expand Down Expand Up @@ -921,6 +925,7 @@ impl Configuration {
Ok(NetworkSettings {
name: self.args.arg_identity.clone(),
chain: format!("{}", self.chain()?),
is_dev_chain: self.is_dev_chain()?,
network_port: net_addresses.0.port(),
rpc_enabled: http_conf.enabled,
rpc_interface: http_conf.interface,
Expand Down
3 changes: 3 additions & 0 deletions rpc/src/v1/helpers/network_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ pub struct NetworkSettings {
pub name: String,
/// Name of the chain we are connected to
pub chain: String,
/// Is development chain
pub is_dev_chain: bool,
/// Networking port
pub network_port: u16,
/// Is JSON-RPC server enabled?
Expand All @@ -38,6 +40,7 @@ impl Default for NetworkSettings {
NetworkSettings {
name: "".into(),
chain: "foundation".into(),
is_dev_chain: false,
network_port: 30303,
rpc_enabled: true,
rpc_interface: "127.0.0.1".into(),
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/v1/impls/light/parity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ impl Parity for ParityClient {
}

fn status(&self) -> Result<()> {
let has_peers = self.settings.chain == "dev" || self.light_dispatch.sync.peer_numbers().connected > 0;
let has_peers = self.settings.is_dev_chain || self.light_dispatch.sync.peer_numbers().connected > 0;
let is_importing = self.light_dispatch.sync.is_major_importing();

if has_peers && !is_importing {
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/v1/impls/parity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ impl<C, M, U, S> Parity for ParityClient<C, M, U> where
}

fn status(&self) -> Result<()> {
let has_peers = self.client.spec_name() == "developmentchain" || self.sync.status().num_peers > 0;
let has_peers = self.settings.is_dev_chain || self.sync.status().num_peers > 0;
let is_warping = match self.snapshot.as_ref().map(|s| s.status()) {
Some(RestorationStatus::Ongoing { .. }) => true,
_ => false,
Expand Down
1 change: 1 addition & 0 deletions rpc/src/v1/tests/mocked/parity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ impl Dependencies {
settings: Arc::new(NetworkSettings {
name: "mynode".to_owned(),
chain: "testchain".to_owned(),
is_dev_chain: false,
network_port: 30303,
rpc_enabled: true,
rpc_interface: "all".to_owned(),
Expand Down

0 comments on commit ec41b47

Please sign in to comment.