@@ -67,6 +67,10 @@ path = "$HOME/.parity/dapps"
|
||||
user = "test_user"
|
||||
pass = "test_pass"
|
||||
|
||||
[ipfs]
|
||||
enable = false
|
||||
port = 5001
|
||||
|
||||
[mining]
|
||||
author = "0xdeadbeefcafe0000000000000000000000000001"
|
||||
engine_signer = "0xdeadbeefcafe0000000000000000000000000001"
|
||||
|
||||
@@ -38,6 +38,10 @@ port = 8080
|
||||
user = "username"
|
||||
pass = "password"
|
||||
|
||||
[ipfs]
|
||||
enable = false
|
||||
port = 5001
|
||||
|
||||
[mining]
|
||||
author = "0xdeadbeefcafe0000000000000000000000000001"
|
||||
engine_signer = "0xdeadbeefcafe0000000000000000000000000001"
|
||||
|
||||
@@ -189,6 +189,12 @@ usage! {
|
||||
or |c: &Config| otry!(c.dapps).pass.clone().map(Some),
|
||||
flag_dapps_apis_all: bool = false, or |_| None,
|
||||
|
||||
// IPFS
|
||||
flag_ipfs_api: bool = false,
|
||||
or |c: &Config| otry!(c.ipfs).enable.clone(),
|
||||
flag_ipfs_api_port: u16 = 5001u16,
|
||||
or |c: &Config| otry!(c.ipfs).port.clone(),
|
||||
|
||||
// -- Sealing/Mining Options
|
||||
flag_author: Option<String> = None,
|
||||
or |c: &Config| otry!(c.mining).author.clone().map(Some),
|
||||
@@ -321,6 +327,7 @@ struct Config {
|
||||
rpc: Option<Rpc>,
|
||||
ipc: Option<Ipc>,
|
||||
dapps: Option<Dapps>,
|
||||
ipfs: Option<Ipfs>,
|
||||
mining: Option<Mining>,
|
||||
footprint: Option<Footprint>,
|
||||
snapshots: Option<Snapshots>,
|
||||
@@ -409,6 +416,12 @@ struct Dapps {
|
||||
pass: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, PartialEq, RustcDecodable)]
|
||||
struct Ipfs {
|
||||
enable: Option<bool>,
|
||||
port: Option<u16>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, PartialEq, RustcDecodable)]
|
||||
struct Mining {
|
||||
author: Option<String>,
|
||||
@@ -482,7 +495,7 @@ struct Misc {
|
||||
mod tests {
|
||||
use super::{
|
||||
Args, ArgsError,
|
||||
Config, Operating, Account, Ui, Network, Rpc, Ipc, Dapps, Mining, Footprint, Snapshots, VM, Misc
|
||||
Config, Operating, Account, Ui, Network, Rpc, Ipc, Dapps, Ipfs, Mining, Footprint, Snapshots, VM, Misc
|
||||
};
|
||||
use toml;
|
||||
|
||||
@@ -637,6 +650,10 @@ mod tests {
|
||||
flag_dapps_pass: Some("test_pass".into()),
|
||||
flag_dapps_apis_all: false,
|
||||
|
||||
// IPFS
|
||||
flag_ipfs_api: false,
|
||||
flag_ipfs_api_port: 5001u16,
|
||||
|
||||
// -- Sealing/Mining Options
|
||||
flag_author: Some("0xdeadbeefcafe0000000000000000000000000001".into()),
|
||||
flag_engine_signer: Some("0xdeadbeefcafe0000000000000000000000000001".into()),
|
||||
@@ -822,6 +839,10 @@ mod tests {
|
||||
user: Some("username".into()),
|
||||
pass: Some("password".into())
|
||||
}),
|
||||
ipfs: Some(Ipfs {
|
||||
enable: Some(false),
|
||||
port: Some(5001)
|
||||
}),
|
||||
mining: Some(Mining {
|
||||
author: Some("0xdeadbeefcafe0000000000000000000000000001".into()),
|
||||
engine_signer: Some("0xdeadbeefcafe0000000000000000000000000001".into()),
|
||||
|
||||
@@ -175,6 +175,9 @@ API and Console Options:
|
||||
--dapps-apis-all Expose all possible RPC APIs on Dapps port.
|
||||
WARNING: INSECURE. Used only for development.
|
||||
(default: {flag_dapps_apis_all})
|
||||
--ipfs-api Enable IPFS-compatible HTTP API. (default: {flag_ipfs_api})
|
||||
--ipfs-api-port PORT Configure on which port the IPFS HTTP API should listen.
|
||||
(default: {flag_ipfs_api_port})
|
||||
|
||||
Sealing/Mining Options:
|
||||
--author ADDRESS Specify the block author (aka "coinbase") address
|
||||
|
||||
@@ -37,6 +37,7 @@ use params::{ResealPolicy, AccountsConfig, GasPricerConfig, MinerExtras};
|
||||
use ethcore_logger::Config as LogConfig;
|
||||
use dir::{self, Directories, default_hypervisor_path, default_local_path, default_data_path};
|
||||
use dapps::Configuration as DappsConfiguration;
|
||||
use ipfs::Configuration as IpfsConfiguration;
|
||||
use signer::{Configuration as SignerConfiguration};
|
||||
use updater::{UpdatePolicy, UpdateFilter, ReleaseTrack};
|
||||
use run::RunCmd;
|
||||
@@ -118,6 +119,7 @@ impl Configuration {
|
||||
let geth_compatibility = self.args.flag_geth;
|
||||
let ui_address = self.ui_port().map(|port| (self.ui_interface(), port));
|
||||
let dapps_conf = self.dapps_config();
|
||||
let ipfs_conf = self.ipfs_config();
|
||||
let signer_conf = self.signer_config();
|
||||
let format = self.format()?;
|
||||
|
||||
@@ -342,6 +344,7 @@ impl Configuration {
|
||||
ui_address: ui_address,
|
||||
net_settings: self.network_settings(),
|
||||
dapps_conf: dapps_conf,
|
||||
ipfs_conf: ipfs_conf,
|
||||
signer_conf: signer_conf,
|
||||
dapp: self.dapp_to_open()?,
|
||||
ui: self.args.cmd_ui,
|
||||
@@ -539,6 +542,13 @@ impl Configuration {
|
||||
}
|
||||
}
|
||||
|
||||
fn ipfs_config(&self) -> IpfsConfiguration {
|
||||
IpfsConfiguration {
|
||||
enabled: self.args.flag_ipfs_api,
|
||||
port: self.args.flag_ipfs_api_port,
|
||||
}
|
||||
}
|
||||
|
||||
fn dapp_to_open(&self) -> Result<Option<String>, String> {
|
||||
if !self.args.cmd_dapp {
|
||||
return Ok(None);
|
||||
@@ -1101,6 +1111,7 @@ mod tests {
|
||||
ui_address: Some(("127.0.0.1".into(), 8180)),
|
||||
net_settings: Default::default(),
|
||||
dapps_conf: Default::default(),
|
||||
ipfs_conf: Default::default(),
|
||||
signer_conf: Default::default(),
|
||||
ui: false,
|
||||
dapp: None,
|
||||
|
||||
16
parity/ipfs.rs
Normal file
16
parity/ipfs.rs
Normal file
@@ -0,0 +1,16 @@
|
||||
pub use parity_ipfs_api::start_server;
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub struct Configuration {
|
||||
pub enabled: bool,
|
||||
pub port: u16,
|
||||
}
|
||||
|
||||
impl Default for Configuration {
|
||||
fn default() -> Self {
|
||||
Configuration {
|
||||
enabled: false,
|
||||
port: 5001,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,6 +56,7 @@ extern crate ethcore_signer;
|
||||
extern crate ethcore_util as util;
|
||||
extern crate ethsync;
|
||||
extern crate parity_hash_fetch as hash_fetch;
|
||||
extern crate parity_ipfs_api;
|
||||
extern crate parity_reactor;
|
||||
extern crate parity_updater as updater;
|
||||
extern crate rpc_cli;
|
||||
@@ -86,6 +87,7 @@ mod cache;
|
||||
mod cli;
|
||||
mod configuration;
|
||||
mod dapps;
|
||||
mod ipfs;
|
||||
mod deprecated;
|
||||
mod dir;
|
||||
mod helpers;
|
||||
|
||||
@@ -47,6 +47,7 @@ use dir::Directories;
|
||||
use cache::CacheConfig;
|
||||
use user_defaults::UserDefaults;
|
||||
use dapps;
|
||||
use ipfs;
|
||||
use signer;
|
||||
use modules;
|
||||
use rpc_apis;
|
||||
@@ -93,6 +94,7 @@ pub struct RunCmd {
|
||||
pub ui_address: Option<(String, u16)>,
|
||||
pub net_settings: NetworkSettings,
|
||||
pub dapps_conf: dapps::Configuration,
|
||||
pub ipfs_conf: ipfs::Configuration,
|
||||
pub signer_conf: signer::Configuration,
|
||||
pub dapp: Option<String>,
|
||||
pub ui: bool,
|
||||
@@ -420,6 +422,12 @@ pub fn execute(cmd: RunCmd, can_restart: bool, logger: Arc<RotatingLogger>) -> R
|
||||
};
|
||||
let signer_server = signer::start(cmd.signer_conf.clone(), signer_deps)?;
|
||||
|
||||
// the ipfs server
|
||||
let ipfs_server = match cmd.ipfs_conf.enabled {
|
||||
true => Some(ipfs::start_server(cmd.ipfs_conf.port, client.clone())?),
|
||||
false => None,
|
||||
};
|
||||
|
||||
// the informant
|
||||
let informant = Arc::new(Informant::new(
|
||||
service.client(),
|
||||
@@ -476,7 +484,7 @@ pub fn execute(cmd: RunCmd, can_restart: bool, logger: Arc<RotatingLogger>) -> R
|
||||
let restart = wait_for_exit(panic_handler, Some(updater), can_restart);
|
||||
|
||||
// drop this stuff as soon as exit detected.
|
||||
drop((http_server, ipc_server, dapps_server, signer_server, event_loop));
|
||||
drop((http_server, ipc_server, dapps_server, signer_server, ipfs_server, event_loop));
|
||||
|
||||
info!("Finishing work, please wait...");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user