Merge branch 'lightcli' into light-filters

This commit is contained in:
Robert Habermeier
2017-04-03 09:03:12 +02:00
469 changed files with 9459 additions and 11074 deletions

View File

@@ -4,6 +4,7 @@ mode_timeout = 300
mode_alarm = 3600
auto_update = "none"
release_track = "current"
public_node = false
no_download = false
no_consensus = false

View File

@@ -88,6 +88,7 @@ usage! {
flag_mode_alarm: u64 = 3600u64, or |c: &Config| otry!(c.parity).mode_alarm.clone(),
flag_auto_update: String = "critical", or |c: &Config| otry!(c.parity).auto_update.clone(),
flag_release_track: String = "current", or |c: &Config| otry!(c.parity).release_track.clone(),
flag_public_node: bool = false, or |c: &Config| otry!(c.parity).public_node.clone(),
flag_no_download: bool = false, or |c: &Config| otry!(c.parity).no_download.clone(),
flag_no_consensus: bool = false, or |c: &Config| otry!(c.parity).no_consensus.clone(),
flag_chain: String = "foundation", or |c: &Config| otry!(c.parity).chain.clone(),
@@ -368,6 +369,7 @@ struct Operating {
mode_alarm: Option<u64>,
auto_update: Option<String>,
release_track: Option<String>,
public_node: Option<bool>,
no_download: Option<bool>,
no_consensus: Option<bool>,
chain: Option<String>,
@@ -628,6 +630,7 @@ mod tests {
flag_mode_alarm: 3600u64,
flag_auto_update: "none".into(),
flag_release_track: "current".into(),
flag_public_node: false,
flag_no_download: false,
flag_no_consensus: false,
flag_chain: "xyz".into(),
@@ -832,6 +835,7 @@ mod tests {
mode_alarm: Some(10u64),
auto_update: None,
release_track: None,
public_node: None,
no_download: None,
no_consensus: None,
chain: Some("./chain.json".into()),

View File

@@ -48,6 +48,9 @@ Operating Options:
testing - Testing releases (do not use).
current - Whatever track this executable was
released on (default: {flag_release_track}).
--public-node Start Parity as a public web server. Account storage
and transaction signing will be delegated to the UI.
(default: {flag_public_node}).
--no-download Normally new releases will be downloaded ready for
updating. This disables it. Not recommended.
(default: {flag_no_download}).

View File

@@ -128,6 +128,7 @@ impl Configuration {
Some(true) if pruning == Pruning::Specific(Algorithm::Archive) => writeln!(&mut stderr(), "Warning: Warp Sync is disabled because pruning mode is set to archive").expect("Error writing to stderr"),
_ => {},
};
let public_node = self.args.flag_public_node;
let warp_sync = !self.args.flag_no_warp && fat_db != Switch::On && tracing != Switch::On && pruning != Pruning::Specific(Algorithm::Archive);
let geth_compatibility = self.args.flag_geth;
let ui_address = self.ui_port().map(|port| (self.ui_interface(), port));
@@ -360,6 +361,7 @@ impl Configuration {
wal: wal,
vm_type: vm_type,
warp_sync: warp_sync,
public_node: public_node,
geth_compatibility: geth_compatibility,
ui_address: ui_address,
net_settings: self.network_settings(),
@@ -711,14 +713,26 @@ impl Configuration {
}
fn rpc_apis(&self) -> String {
let mut apis = self.args.flag_rpcapi.clone().unwrap_or(self.args.flag_jsonrpc_apis.clone());
let mut apis: Vec<&str> = self.args.flag_rpcapi
.as_ref()
.unwrap_or(&self.args.flag_jsonrpc_apis)
.split(",")
.collect();
if self.args.flag_geth {
if !apis.is_empty() {
apis.push_str(",");
}
apis.push_str("personal");
apis.push("personal");
}
apis
if self.args.flag_public_node {
apis.retain(|api| {
match *api {
"eth" | "net" | "parity" | "rpc" | "web3" => true,
_ => false
}
});
}
apis.join(",")
}
fn cors(cors: Option<&String>) -> Option<Vec<String>> {
@@ -1169,6 +1183,7 @@ mod tests {
ipc_conf: Default::default(),
net_conf: default_network_config(),
network_id: None,
public_node: false,
warp_sync: true,
acc_conf: Default::default(),
gas_pricer: Default::default(),

View File

@@ -152,7 +152,7 @@ pub struct FullDependencies {
pub snapshot: Arc<SnapshotService>,
pub sync: Arc<SyncProvider>,
pub net: Arc<ManageNetwork>,
pub secret_store: Arc<AccountProvider>,
pub secret_store: Option<Arc<AccountProvider>>,
pub miner: Arc<Miner>,
pub external_miner: Arc<ExternalMiner>,
pub logger: Arc<RotatingLogger>,
@@ -318,10 +318,15 @@ impl Dependencies for LightDependencies {
{
let deps = &$deps;
let dispatcher = dispatcher.clone();
let secret_store = Some(deps.secret_store.clone());
if deps.signer_service.is_enabled() {
$handler.extend_with($namespace::to_delegate(SigningQueueClient::new(&deps.signer_service, dispatcher, &deps.secret_store)))
$handler.extend_with($namespace::to_delegate(
SigningQueueClient::new(&deps.signer_service, dispatcher, &secret_store)
))
} else {
$handler.extend_with($namespace::to_delegate(SigningUnsafeClient::new(&deps.secret_store, dispatcher)))
$handler.extend_with(
$namespace::to_delegate(SigningUnsafeClient::new(&secret_store, dispatcher))
)
}
}
}
@@ -349,10 +354,12 @@ impl Dependencies for LightDependencies {
add_signing_methods!(EthSigning, handler, self);
},
Api::Personal => {
handler.extend_with(PersonalClient::new(&self.secret_store, dispatcher.clone(), self.geth_compatibility).to_delegate());
let secret_store = Some(self.secret_store.clone());
handler.extend_with(PersonalClient::new(&secret_store, dispatcher.clone(), self.geth_compatibility).to_delegate());
},
Api::Signer => {
handler.extend_with(SignerClient::new(&self.secret_store, dispatcher.clone(), &self.signer_service).to_delegate());
let secret_store = Some(self.secret_store.clone());
handler.extend_with(SignerClient::new(&secret_store, dispatcher.clone(), &self.signer_service).to_delegate());
},
Api::Parity => {
let signer = match self.signer_service.is_enabled() {
@@ -373,7 +380,8 @@ impl Dependencies for LightDependencies {
add_signing_methods!(ParitySigning, handler, self);
},
Api::ParityAccounts => {
handler.extend_with(ParityAccountsClient::new(&self.secret_store).to_delegate());
let secret_store = Some(self.secret_store.clone());
handler.extend_with(ParityAccountsClient::new(&secret_store).to_delegate());
},
Api::ParitySet => {
handler.extend_with(light::ParitySetClient::new(

View File

@@ -86,6 +86,7 @@ pub struct RunCmd {
pub net_conf: NetworkConfiguration,
pub network_id: Option<u64>,
pub warp_sync: bool,
pub public_node: bool,
pub acc_conf: AccountsConfig,
pub gas_pricer: GasPricerConfig,
pub miner_extras: MinerExtras,
@@ -586,6 +587,11 @@ pub fn execute(cmd: RunCmd, can_restart: bool, logger: Arc<RotatingLogger>) -> R
// set up dependencies for rpc servers
let rpc_stats = Arc::new(informant::RpcStats::default());
let signer_path = cmd.signer_conf.signer_path.clone();
let secret_store = match cmd.public_node {
true => None,
false => Some(account_provider.clone())
};
let deps_for_rpc_apis = Arc::new(rpc_apis::FullDependencies {
signer_service: Arc::new(rpc_apis::SignerService::new(move || {
signer::generate_new_token(signer_path.clone()).map_err(|e| format!("{:?}", e))
@@ -594,7 +600,7 @@ pub fn execute(cmd: RunCmd, can_restart: bool, logger: Arc<RotatingLogger>) -> R
client: client.clone(),
sync: sync_provider.clone(),
net: manage_network.clone(),
secret_store: account_provider.clone(),
secret_store: secret_store,
miner: miner.clone(),
external_miner: external_miner.clone(),
logger: logger.clone(),