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

cleaned up parity/signer #1551

Merged
merged 5 commits into from
Jul 11, 2016
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
7 changes: 3 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ ethcore = { path = "ethcore" }
ethcore-util = { path = "util" }
ethsync = { path = "sync" }
ethcore-devtools = { path = "devtools" }
ethcore-rpc = { path = "rpc", optional = true }
ethcore-signer = { path = "signer", optional = true }
ethcore-rpc = { path = "rpc" }
ethcore-signer = { path = "signer" }
ethcore-dapps = { path = "dapps", optional = true }
semver = "0.2"
ethcore-ipc-nano = { path = "ipc/nano" }
Expand All @@ -48,8 +48,7 @@ version = "0.8"
default-features = false

[features]
default = ["rpc", "dapps", "ethcore-signer"]
rpc = ["ethcore-rpc"]
default = ["dapps"]
dapps = ["ethcore-dapps"]
dev = ["clippy", "ethcore/dev", "ethcore-util/dev", "ethsync/dev", "ethcore-rpc/dev",
"ethcore-dapps/dev", "ethcore-signer/dev"]
Expand Down
8 changes: 3 additions & 5 deletions parity/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,14 @@ extern crate hyper; // for price_info.rs
extern crate json_ipc_server as jsonipc;

extern crate ethcore_ipc_hypervisor as hypervisor;

#[cfg(feature = "rpc")]
extern crate ethcore_rpc;

extern crate ethcore_signer;
extern crate ansi_term;

#[cfg(feature = "dapps")]
extern crate ethcore_dapps;

#[cfg(feature = "ethcore-signer")]
extern crate ethcore_signer;

#[macro_use]
mod die;
mod upgrade;
Expand Down
21 changes: 0 additions & 21 deletions parity/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,8 @@ use jsonipc;
use rpc_apis;
use std::fmt;

#[cfg(feature = "rpc")]
pub use ethcore_rpc::Server as RpcServer;
#[cfg(feature = "rpc")]
use ethcore_rpc::{RpcServerError, RpcServer as Server};
#[cfg(not(feature = "rpc"))]
pub struct RpcServer;

pub struct HttpConfiguration {
pub enabled: bool,
Expand Down Expand Up @@ -79,17 +75,6 @@ fn setup_rpc_server(apis: Vec<&str>, deps: &Dependencies) -> Server {
rpc_apis::setup_rpc(server, deps.apis.clone(), rpc_apis::ApiSet::List(apis))
}

#[cfg(not(feature = "rpc"))]
pub fn setup_http_rpc_server(
_deps: &Dependencies,
_url: &SocketAddr,
_cors_domain: Vec<String>,
_apis: Vec<&str>,
) -> ! {
die!("Your Parity version has been compiled without JSON-RPC support.")
}

#[cfg(feature = "rpc")]
pub fn setup_http_rpc_server(
dependencies: &Dependencies,
url: &SocketAddr,
Expand All @@ -111,18 +96,12 @@ pub fn setup_http_rpc_server(
}
}

#[cfg(not(feature = "rpc"))]
pub fn setup_ipc_rpc_server(_dependencies: &Dependencies, _addr: &str, _apis: Vec<&str>) -> ! {
die!("Your Parity version has been compiled without JSON-RPC support.")
}

pub fn new_ipc(conf: IpcConfiguration, deps: &Dependencies) -> Option<jsonipc::Server> {
if !conf.enabled { return None; }
let apis = conf.apis.split(',').collect();
Some(setup_ipc_rpc_server(deps, &conf.socket_addr, apis))
}

#[cfg(feature = "rpc")]
pub fn setup_ipc_rpc_server(dependencies: &Dependencies, addr: &str, apis: Vec<&str>) -> jsonipc::Server {
let server = setup_rpc_server(apis, dependencies);
match server.start_ipc(addr) {
Expand Down
5 changes: 0 additions & 5 deletions parity/rpc_apis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,8 @@ use ethcore::account_provider::AccountProvider;
use util::network_settings::NetworkSettings;
use util::network::NetworkService;

#[cfg(feature="rpc")]
pub use ethcore_rpc::ConfirmationsQueue;
#[cfg(not(feature="rpc"))]
#[derive(Default)]
pub struct ConfirmationsQueue;

#[cfg(feature="rpc")]
use ethcore_rpc::Extendable;

pub enum Api {
Expand Down
30 changes: 7 additions & 23 deletions parity/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,19 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

use std::io;
use std::path::PathBuf;
use std::sync::Arc;
use util::{Colour, Applyable};
use util::panics::{PanicHandler, ForwardPanic};
use std::path::PathBuf;
use ansi_term::Colour;
use util::panics::{ForwardPanic, PanicHandler};
use util::path::restrict_permissions_owner;
use die::*;
use util::Applyable;
use rpc_apis;

const CODES_FILENAME: &'static str = "authcodes";

#[cfg(feature = "ethcore-signer")]
use ethcore_signer as signer;
#[cfg(feature = "ethcore-signer")]
use die::*;

pub use ethcore_signer::Server as SignerServer;

#[cfg(not(feature = "ethcore-signer"))]
pub struct SignerServer;
const CODES_FILENAME: &'static str = "authcodes";

pub struct Configuration {
pub enabled: bool,
Expand Down Expand Up @@ -59,8 +55,6 @@ fn codes_path(path: String) -> PathBuf {
p
}


#[cfg(feature = "ethcore-signer")]
pub fn new_token(path: String) -> io::Result<()> {
let path = codes_path(path);
let mut codes = try!(signer::AuthCodes::from_file(&path));
Expand All @@ -70,7 +64,6 @@ pub fn new_token(path: String) -> io::Result<()> {
Ok(())
}

#[cfg(feature = "ethcore-signer")]
fn do_start(conf: Configuration, deps: Dependencies) -> SignerServer {
let addr = format!("127.0.0.1:{}", conf.port).parse().unwrap_or_else(|_| {
die!("Invalid port specified: {}", conf.port)
Expand All @@ -95,13 +88,4 @@ fn do_start(conf: Configuration, deps: Dependencies) -> SignerServer {
}
}

#[cfg(not(feature = "ethcore-signer"))]
fn do_start(_conf: Configuration) -> ! {
die!("Your Parity version has been compiled without Trusted Signer support.")
}

#[cfg(not(feature = "ethcore-signer"))]
pub fn new_token(_path: String) -> ! {
die!("Your Parity version has been compiled without Trusted Signer support.")
}