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

Removed obsolete IpcMode enum #8819

Merged
merged 1 commit into from
Jun 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions ethcore/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ use trace;
use trace::{TraceDB, ImportRequest as TraceImportRequest, LocalizedTrace, Database as TraceDatabase};
use transaction::{self, LocalizedTransaction, UnverifiedTransaction, SignedTransaction, Transaction, Action};
use types::filter::Filter;
use types::mode::Mode as IpcMode;
use types::ancestry_action::AncestryAction;
use verification;
use verification::{PreverifiedBlock, Verifier};
Expand Down Expand Up @@ -1564,19 +1563,19 @@ impl BlockChainClient for Client {
})))
}

fn mode(&self) -> IpcMode {
fn mode(&self) -> Mode {
let r = self.mode.lock().clone().into();
trace!(target: "mode", "Asked for mode = {:?}. returning {:?}", &*self.mode.lock(), r);
r
}

fn disable(&self) {
self.set_mode(IpcMode::Off);
self.set_mode(Mode::Off);
self.enabled.store(false, AtomicOrdering::Relaxed);
self.clear_queue();
}

fn set_mode(&self, new_mode: IpcMode) {
fn set_mode(&self, new_mode: Mode) {
trace!(target: "mode", "Client::set_mode({:?})", new_mode);
if !self.enabled.load(AtomicOrdering::Relaxed) {
return;
Expand All @@ -1591,8 +1590,8 @@ impl BlockChainClient for Client {
}
}
match new_mode {
IpcMode::Active => self.wake_up(),
IpcMode::Off => self.sleep(),
Mode::Active => self.wake_up(),
Mode::Off => self.sleep(),
_ => {(*self.sleep_state.lock()).last_activity = Some(Instant::now()); }
}
}
Expand Down
23 changes: 0 additions & 23 deletions ethcore/src/client/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use std::str::FromStr;
use std::fmt::{Display, Formatter, Error as FmtError};

use mode::Mode as IpcMode;
use verification::{VerifierType, QueueConfig};
use journaldb;

Expand Down Expand Up @@ -88,28 +87,6 @@ impl Display for Mode {
}
}

impl Into<IpcMode> for Mode {
fn into(self) -> IpcMode {
match self {
Mode::Off => IpcMode::Off,
Mode::Dark(timeout) => IpcMode::Dark(timeout.as_secs()),
Mode::Passive(timeout, alarm) => IpcMode::Passive(timeout.as_secs(), alarm.as_secs()),
Mode::Active => IpcMode::Active,
}
}
}

impl From<IpcMode> for Mode {
fn from(mode: IpcMode) -> Self {
match mode {
IpcMode::Off => Mode::Off,
IpcMode::Dark(timeout) => Mode::Dark(Duration::from_secs(timeout)),
IpcMode::Passive(timeout, alarm) => Mode::Passive(Duration::from_secs(timeout), Duration::from_secs(alarm)),
IpcMode::Active => Mode::Active,
}
}
}

/// Client configuration. Includes configs for all sub-systems.
#[derive(Debug, PartialEq, Default)]
pub struct ClientConfig {
Expand Down
3 changes: 1 addition & 2 deletions ethcore/src/client/test_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use transaction::{self, Transaction, LocalizedTransaction, SignedTransaction, Ac
use blockchain::{TreeRoute, BlockReceipts};
use client::{
Nonce, Balance, ChainInfo, BlockInfo, ReopenBlock, CallContract, TransactionInfo, RegistryInfo,
PrepareOpenBlock, BlockChainClient, BlockChainInfo, BlockStatus, BlockId,
PrepareOpenBlock, BlockChainClient, BlockChainInfo, BlockStatus, BlockId, Mode,
TransactionId, UncleId, TraceId, TraceFilter, LastHashes, CallAnalytics, BlockImportError,
ProvingBlockChainClient, ScheduleInfo, ImportSealedBlock, BroadcastProposalBlock, ImportBlock, StateOrBlock,
Call, StateClient, EngineInfo, AccountData, BlockChain, BlockProducer, SealedBlockImporter, IoClient
Expand All @@ -51,7 +51,6 @@ use vm::Schedule;
use miner::{Miner, MinerService};
use spec::Spec;
use types::basic_account::BasicAccount;
use types::mode::Mode;
use types::pruning_info::PruningInfo;

use verification::queue::QueueInfo;
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/client/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use itertools::Itertools;

use block::{OpenBlock, SealedBlock, ClosedBlock};
use blockchain::TreeRoute;
use client::Mode;
use encoded;
use vm::LastHashes;
use error::{ImportResult, CallError, BlockImportError};
Expand Down Expand Up @@ -48,7 +49,6 @@ use types::trace_filter::Filter as TraceFilter;
use types::call_analytics::CallAnalytics;
use types::blockchain_info::BlockChainInfo;
use types::block_status::BlockStatus;
use types::mode::Mode;
use types::pruning_info::PruningInfo;

/// State information to be used during client query
Expand Down
1 change: 0 additions & 1 deletion ethcore/types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ pub mod call_analytics;
pub mod filter;
pub mod ids;
pub mod log_entry;
pub mod mode;
pub mod pruning_info;
pub mod receipt;
pub mod restoration_status;
Expand Down
32 changes: 0 additions & 32 deletions ethcore/types/src/mode.rs

This file was deleted.

8 changes: 1 addition & 7 deletions rpc/src/v1/impls/parity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ use ethcore::account_provider::AccountProvider;
use ethcore::client::{BlockChainClient, StateClient, Call};
use ethcore::ids::BlockId;
use ethcore::miner::{self, MinerService};
use ethcore::mode::Mode;
use ethcore::state::StateInfo;
use ethcore_logger::RotatingLogger;
use node_health::{NodeHealth, Health};
Expand Down Expand Up @@ -365,12 +364,7 @@ impl<C, M, U, S> Parity for ParityClient<C, M, U> where
}

fn mode(&self) -> Result<String> {
Ok(match self.client.mode() {
Mode::Off => "offline",
Mode::Dark(..) => "dark",
Mode::Passive(..) => "passive",
Mode::Active => "active",
}.into())
Ok(self.client.mode().to_string())
}

fn enode(&self) -> Result<String> {
Expand Down
8 changes: 4 additions & 4 deletions rpc/src/v1/impls/parity_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
/// Parity-specific rpc interface for operations altering the settings.
use std::io;
use std::sync::Arc;
use std::time::Duration;

use ethcore::client::BlockChainClient;
use ethcore::client::{BlockChainClient, Mode};
use ethcore::miner::MinerService;
use ethcore::mode::Mode;
use sync::ManageNetwork;
use fetch::{self, Fetch};
use futures_cpupool::CpuPool;
Expand Down Expand Up @@ -160,8 +160,8 @@ impl<C, M, U, F> ParitySet for ParitySetClient<C, M, U, F> where
fn set_mode(&self, mode: String) -> Result<bool> {
self.client.set_mode(match mode.as_str() {
"offline" => Mode::Off,
"dark" => Mode::Dark(300),
"passive" => Mode::Passive(300, 3600),
"dark" => Mode::Dark(Duration::from_secs(300)),
"passive" => Mode::Passive(Duration::from_secs(300), Duration::from_secs(3600)),
"active" => Mode::Active,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not constify these Durations?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will prepare another pr

e => { return Err(errors::invalid_params("mode", e.to_owned())); },
});
Expand Down