Removed obsolete IpcMode enum (#8819)
This commit is contained in:
parent
a5190449da
commit
107f0fa4c6
@ -72,7 +72,6 @@ use trace;
|
|||||||
use trace::{TraceDB, ImportRequest as TraceImportRequest, LocalizedTrace, Database as TraceDatabase};
|
use trace::{TraceDB, ImportRequest as TraceImportRequest, LocalizedTrace, Database as TraceDatabase};
|
||||||
use transaction::{self, LocalizedTransaction, UnverifiedTransaction, SignedTransaction, Transaction, Action};
|
use transaction::{self, LocalizedTransaction, UnverifiedTransaction, SignedTransaction, Transaction, Action};
|
||||||
use types::filter::Filter;
|
use types::filter::Filter;
|
||||||
use types::mode::Mode as IpcMode;
|
|
||||||
use types::ancestry_action::AncestryAction;
|
use types::ancestry_action::AncestryAction;
|
||||||
use verification;
|
use verification;
|
||||||
use verification::{PreverifiedBlock, Verifier};
|
use verification::{PreverifiedBlock, Verifier};
|
||||||
@ -1570,19 +1569,19 @@ impl BlockChainClient for Client {
|
|||||||
})))
|
})))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mode(&self) -> IpcMode {
|
fn mode(&self) -> Mode {
|
||||||
let r = self.mode.lock().clone().into();
|
let r = self.mode.lock().clone().into();
|
||||||
trace!(target: "mode", "Asked for mode = {:?}. returning {:?}", &*self.mode.lock(), r);
|
trace!(target: "mode", "Asked for mode = {:?}. returning {:?}", &*self.mode.lock(), r);
|
||||||
r
|
r
|
||||||
}
|
}
|
||||||
|
|
||||||
fn disable(&self) {
|
fn disable(&self) {
|
||||||
self.set_mode(IpcMode::Off);
|
self.set_mode(Mode::Off);
|
||||||
self.enabled.store(false, AtomicOrdering::Relaxed);
|
self.enabled.store(false, AtomicOrdering::Relaxed);
|
||||||
self.clear_queue();
|
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);
|
trace!(target: "mode", "Client::set_mode({:?})", new_mode);
|
||||||
if !self.enabled.load(AtomicOrdering::Relaxed) {
|
if !self.enabled.load(AtomicOrdering::Relaxed) {
|
||||||
return;
|
return;
|
||||||
@ -1597,8 +1596,8 @@ impl BlockChainClient for Client {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
match new_mode {
|
match new_mode {
|
||||||
IpcMode::Active => self.wake_up(),
|
Mode::Active => self.wake_up(),
|
||||||
IpcMode::Off => self.sleep(),
|
Mode::Off => self.sleep(),
|
||||||
_ => {(*self.sleep_state.lock()).last_activity = Some(Instant::now()); }
|
_ => {(*self.sleep_state.lock()).last_activity = Some(Instant::now()); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::fmt::{Display, Formatter, Error as FmtError};
|
use std::fmt::{Display, Formatter, Error as FmtError};
|
||||||
|
|
||||||
use mode::Mode as IpcMode;
|
|
||||||
use verification::{VerifierType, QueueConfig};
|
use verification::{VerifierType, QueueConfig};
|
||||||
use journaldb;
|
use journaldb;
|
||||||
|
|
||||||
@ -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.
|
/// Client configuration. Includes configs for all sub-systems.
|
||||||
#[derive(Debug, PartialEq, Default)]
|
#[derive(Debug, PartialEq, Default)]
|
||||||
pub struct ClientConfig {
|
pub struct ClientConfig {
|
||||||
|
@ -36,7 +36,7 @@ use transaction::{self, Transaction, LocalizedTransaction, SignedTransaction, Ac
|
|||||||
use blockchain::{TreeRoute, BlockReceipts};
|
use blockchain::{TreeRoute, BlockReceipts};
|
||||||
use client::{
|
use client::{
|
||||||
Nonce, Balance, ChainInfo, BlockInfo, ReopenBlock, CallContract, TransactionInfo, RegistryInfo,
|
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,
|
TransactionId, UncleId, TraceId, TraceFilter, LastHashes, CallAnalytics, BlockImportError,
|
||||||
ProvingBlockChainClient, ScheduleInfo, ImportSealedBlock, BroadcastProposalBlock, ImportBlock, StateOrBlock,
|
ProvingBlockChainClient, ScheduleInfo, ImportSealedBlock, BroadcastProposalBlock, ImportBlock, StateOrBlock,
|
||||||
Call, StateClient, EngineInfo, AccountData, BlockChain, BlockProducer, SealedBlockImporter, IoClient
|
Call, StateClient, EngineInfo, AccountData, BlockChain, BlockProducer, SealedBlockImporter, IoClient
|
||||||
@ -51,7 +51,6 @@ use vm::Schedule;
|
|||||||
use miner::{Miner, MinerService};
|
use miner::{Miner, MinerService};
|
||||||
use spec::Spec;
|
use spec::Spec;
|
||||||
use types::basic_account::BasicAccount;
|
use types::basic_account::BasicAccount;
|
||||||
use types::mode::Mode;
|
|
||||||
use types::pruning_info::PruningInfo;
|
use types::pruning_info::PruningInfo;
|
||||||
|
|
||||||
use verification::queue::QueueInfo;
|
use verification::queue::QueueInfo;
|
||||||
|
@ -21,6 +21,7 @@ use itertools::Itertools;
|
|||||||
|
|
||||||
use block::{OpenBlock, SealedBlock, ClosedBlock};
|
use block::{OpenBlock, SealedBlock, ClosedBlock};
|
||||||
use blockchain::TreeRoute;
|
use blockchain::TreeRoute;
|
||||||
|
use client::Mode;
|
||||||
use encoded;
|
use encoded;
|
||||||
use vm::LastHashes;
|
use vm::LastHashes;
|
||||||
use error::{ImportResult, CallError, BlockImportError};
|
use error::{ImportResult, CallError, BlockImportError};
|
||||||
@ -48,7 +49,6 @@ use types::trace_filter::Filter as TraceFilter;
|
|||||||
use types::call_analytics::CallAnalytics;
|
use types::call_analytics::CallAnalytics;
|
||||||
use types::blockchain_info::BlockChainInfo;
|
use types::blockchain_info::BlockChainInfo;
|
||||||
use types::block_status::BlockStatus;
|
use types::block_status::BlockStatus;
|
||||||
use types::mode::Mode;
|
|
||||||
use types::pruning_info::PruningInfo;
|
use types::pruning_info::PruningInfo;
|
||||||
|
|
||||||
/// State information to be used during client query
|
/// State information to be used during client query
|
||||||
|
@ -36,7 +36,6 @@ pub mod call_analytics;
|
|||||||
pub mod filter;
|
pub mod filter;
|
||||||
pub mod ids;
|
pub mod ids;
|
||||||
pub mod log_entry;
|
pub mod log_entry;
|
||||||
pub mod mode;
|
|
||||||
pub mod pruning_info;
|
pub mod pruning_info;
|
||||||
pub mod receipt;
|
pub mod receipt;
|
||||||
pub mod restoration_status;
|
pub mod restoration_status;
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
|
|
||||||
// This file is part of Parity.
|
|
||||||
|
|
||||||
// Parity is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
|
|
||||||
// Parity is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
//! Mode type
|
|
||||||
|
|
||||||
pub use std::time::Duration;
|
|
||||||
|
|
||||||
/// IPC-capable shadow-type for `client::config::Mode`
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub enum Mode {
|
|
||||||
/// Same as `ClientMode::Off`.
|
|
||||||
Off,
|
|
||||||
/// Same as `ClientMode::Dark`; values in seconds.
|
|
||||||
Dark(u64),
|
|
||||||
/// Same as `ClientMode::Passive`; values in seconds.
|
|
||||||
Passive(u64, u64),
|
|
||||||
/// Same as `ClientMode::Active`.
|
|
||||||
Active,
|
|
||||||
}
|
|
@ -30,7 +30,6 @@ use ethcore::account_provider::AccountProvider;
|
|||||||
use ethcore::client::{BlockChainClient, StateClient, Call};
|
use ethcore::client::{BlockChainClient, StateClient, Call};
|
||||||
use ethcore::ids::BlockId;
|
use ethcore::ids::BlockId;
|
||||||
use ethcore::miner::{self, MinerService};
|
use ethcore::miner::{self, MinerService};
|
||||||
use ethcore::mode::Mode;
|
|
||||||
use ethcore::state::StateInfo;
|
use ethcore::state::StateInfo;
|
||||||
use ethcore_logger::RotatingLogger;
|
use ethcore_logger::RotatingLogger;
|
||||||
use node_health::{NodeHealth, Health};
|
use node_health::{NodeHealth, Health};
|
||||||
@ -365,12 +364,7 @@ impl<C, M, U, S> Parity for ParityClient<C, M, U> where
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn mode(&self) -> Result<String> {
|
fn mode(&self) -> Result<String> {
|
||||||
Ok(match self.client.mode() {
|
Ok(self.client.mode().to_string())
|
||||||
Mode::Off => "offline",
|
|
||||||
Mode::Dark(..) => "dark",
|
|
||||||
Mode::Passive(..) => "passive",
|
|
||||||
Mode::Active => "active",
|
|
||||||
}.into())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn enode(&self) -> Result<String> {
|
fn enode(&self) -> Result<String> {
|
||||||
|
@ -17,10 +17,10 @@
|
|||||||
/// Parity-specific rpc interface for operations altering the settings.
|
/// Parity-specific rpc interface for operations altering the settings.
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
use ethcore::client::BlockChainClient;
|
use ethcore::client::{BlockChainClient, Mode};
|
||||||
use ethcore::miner::MinerService;
|
use ethcore::miner::MinerService;
|
||||||
use ethcore::mode::Mode;
|
|
||||||
use sync::ManageNetwork;
|
use sync::ManageNetwork;
|
||||||
use fetch::{self, Fetch};
|
use fetch::{self, Fetch};
|
||||||
use futures_cpupool::CpuPool;
|
use futures_cpupool::CpuPool;
|
||||||
@ -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> {
|
fn set_mode(&self, mode: String) -> Result<bool> {
|
||||||
self.client.set_mode(match mode.as_str() {
|
self.client.set_mode(match mode.as_str() {
|
||||||
"offline" => Mode::Off,
|
"offline" => Mode::Off,
|
||||||
"dark" => Mode::Dark(300),
|
"dark" => Mode::Dark(Duration::from_secs(300)),
|
||||||
"passive" => Mode::Passive(300, 3600),
|
"passive" => Mode::Passive(Duration::from_secs(300), Duration::from_secs(3600)),
|
||||||
"active" => Mode::Active,
|
"active" => Mode::Active,
|
||||||
e => { return Err(errors::invalid_params("mode", e.to_owned())); },
|
e => { return Err(errors::invalid_params("mode", e.to_owned())); },
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user