whisper is no longer a part of parity-ethereum repo (#10855)
* whisper is no longer a part of parity-ethereum repo * fix failing tests * update whisper help with the link to the new repo * Removed AttachedProtocols * updated whisper info in README.md files * Update parity/deprecated.rs Co-Authored-By: Andronik Ordian <write@reusable.software>
This commit is contained in:
@@ -494,9 +494,9 @@ usage! {
|
||||
"--jsonrpc-interface=[IP]",
|
||||
"Specify the hostname portion of the HTTP JSON-RPC API server, IP should be an interface's IP address, or all (all interfaces) or local.",
|
||||
|
||||
ARG arg_jsonrpc_apis: (String) = "web3,eth,pubsub,net,parity,private,parity_pubsub,traces,rpc,shh,shh_pubsub,parity_transactions_pool", or |c: &Config| c.rpc.as_ref()?.apis.as_ref().map(|vec| vec.join(",")),
|
||||
ARG arg_jsonrpc_apis: (String) = "web3,eth,pubsub,net,parity,private,parity_pubsub,traces,rpc,parity_transactions_pool", or |c: &Config| c.rpc.as_ref()?.apis.as_ref().map(|vec| vec.join(",")),
|
||||
"--jsonrpc-apis=[APIS]",
|
||||
"Specify the APIs available through the HTTP JSON-RPC interface using a comma-delimited list of API names. Possible names are: all, safe, debug, web3, net, eth, pubsub, personal, signer, parity, parity_pubsub, parity_accounts, parity_set, traces, rpc, secretstore, shh, shh_pubsub. You can also disable a specific API by putting '-' in the front, example: all,-personal. 'safe' enables the following APIs: web3, net, eth, pubsub, parity, parity_pubsub, traces, rpc, shh, shh_pubsub",
|
||||
"Specify the APIs available through the HTTP JSON-RPC interface using a comma-delimited list of API names. Possible names are: all, safe, debug, web3, net, eth, pubsub, personal, signer, parity, parity_pubsub, parity_accounts, parity_set, traces, rpc, secretstore. You can also disable a specific API by putting '-' in the front, example: all,-personal. 'safe' enables the following APIs: web3, net, eth, pubsub, parity, parity_pubsub, traces, rpc",
|
||||
|
||||
ARG arg_jsonrpc_hosts: (String) = "none", or |c: &Config| c.rpc.as_ref()?.hosts.as_ref().map(|vec| vec.join(",")),
|
||||
"--jsonrpc-hosts=[HOSTS]",
|
||||
@@ -535,9 +535,9 @@ usage! {
|
||||
"--ws-interface=[IP]",
|
||||
"Specify the hostname portion of the WebSockets JSON-RPC server, IP should be an interface's IP address, or all (all interfaces) or local.",
|
||||
|
||||
ARG arg_ws_apis: (String) = "web3,eth,pubsub,net,parity,parity_pubsub,private,traces,rpc,shh,shh_pubsub,parity_transactions_pool", or |c: &Config| c.websockets.as_ref()?.apis.as_ref().map(|vec| vec.join(",")),
|
||||
ARG arg_ws_apis: (String) = "web3,eth,pubsub,net,parity,parity_pubsub,private,traces,rpc,parity_transactions_pool", or |c: &Config| c.websockets.as_ref()?.apis.as_ref().map(|vec| vec.join(",")),
|
||||
"--ws-apis=[APIS]",
|
||||
"Specify the JSON-RPC APIs available through the WebSockets interface using a comma-delimited list of API names. Possible names are: all, safe, web3, net, eth, pubsub, personal, signer, parity, parity_pubsub, parity_accounts, parity_set, traces, rpc, secretstore, shh, shh_pubsub. You can also disable a specific API by putting '-' in the front, example: all,-personal. 'safe' enables the following APIs: web3, net, eth, pubsub, parity, parity_pubsub, traces, rpc, shh, shh_pubsub",
|
||||
"Specify the JSON-RPC APIs available through the WebSockets interface using a comma-delimited list of API names. Possible names are: all, safe, web3, net, eth, pubsub, personal, signer, parity, parity_pubsub, parity_accounts, parity_set, traces, rpc, secretstore. You can also disable a specific API by putting '-' in the front, example: all,-personal. 'safe' enables the following APIs: web3, net, eth, pubsub, parity, parity_pubsub, traces, rpc",
|
||||
|
||||
ARG arg_ws_origins: (String) = "parity://*,chrome-extension://*,moz-extension://*", or |c: &Config| c.websockets.as_ref()?.origins.as_ref().map(|vec| vec.join(",")),
|
||||
"--ws-origins=[URL]",
|
||||
@@ -560,9 +560,9 @@ usage! {
|
||||
"--ipc-path=[PATH]",
|
||||
"Specify custom path for JSON-RPC over IPC service.",
|
||||
|
||||
ARG arg_ipc_apis: (String) = "web3,eth,pubsub,net,parity,parity_pubsub,parity_accounts,private,traces,rpc,shh,shh_pubsub,parity_transactions_pool", or |c: &Config| c.ipc.as_ref()?.apis.as_ref().map(|vec| vec.join(",")),
|
||||
ARG arg_ipc_apis: (String) = "web3,eth,pubsub,net,parity,parity_pubsub,parity_accounts,private,traces,rpc,parity_transactions_pool", or |c: &Config| c.ipc.as_ref()?.apis.as_ref().map(|vec| vec.join(",")),
|
||||
"--ipc-apis=[APIS]",
|
||||
"Specify custom API set available via JSON-RPC over IPC using a comma-delimited list of API names. Possible names are: all, safe, web3, net, eth, pubsub, personal, signer, parity, parity_pubsub, parity_accounts, parity_set, traces, rpc, secretstore, shh, shh_pubsub. You can also disable a specific API by putting '-' in the front, example: all,-personal. 'safe' enables the following APIs: web3, net, eth, pubsub, parity, parity_pubsub, traces, rpc, shh, shh_pubsub",
|
||||
"Specify custom API set available via JSON-RPC over IPC using a comma-delimited list of API names. Possible names are: all, safe, web3, net, eth, pubsub, personal, signer, parity, parity_pubsub, parity_accounts, parity_set, traces, rpc, secretstore. You can also disable a specific API by putting '-' in the front, example: all,-personal. 'safe' enables the following APIs: web3, net, eth, pubsub, parity, parity_pubsub, traces, rpc",
|
||||
|
||||
["API and Console Options – IPFS"]
|
||||
FLAG flag_ipfs_api: (bool) = false, or |c: &Config| c.ipfs.as_ref()?.enable.clone(),
|
||||
@@ -926,11 +926,11 @@ usage! {
|
||||
["Whisper Options"]
|
||||
FLAG flag_whisper: (bool) = false, or |c: &Config| c.whisper.as_ref()?.enabled,
|
||||
"--whisper",
|
||||
"Enable the Whisper network.",
|
||||
"Does nothing. Whisper has been moved to https://github.com/paritytech/whisper",
|
||||
|
||||
ARG arg_whisper_pool_size: (usize) = 10usize, or |c: &Config| c.whisper.as_ref()?.pool_size.clone(),
|
||||
ARG arg_whisper_pool_size: (Option<usize>) = None, or |c: &Config| c.whisper.as_ref()?.pool_size.clone(),
|
||||
"--whisper-pool-size=[MB]",
|
||||
"Target size of the whisper message pool in megabytes.",
|
||||
"Does nothing. Whisper has been moved to https://github.com/paritytech/whisper",
|
||||
|
||||
["Legacy Options"]
|
||||
// Options that are hidden from config, but are still unique for its functionality.
|
||||
@@ -1942,7 +1942,7 @@ mod tests {
|
||||
|
||||
// -- Whisper options.
|
||||
flag_whisper: false,
|
||||
arg_whisper_pool_size: 20,
|
||||
arg_whisper_pool_size: Some(20),
|
||||
|
||||
// -- Legacy Options
|
||||
flag_warp: false,
|
||||
|
||||
@@ -362,7 +362,6 @@ impl Configuration {
|
||||
};
|
||||
|
||||
let verifier_settings = self.verifier_settings();
|
||||
let whisper_config = self.whisper_config();
|
||||
let (private_provider_conf, private_enc_conf, private_tx_enabled) = self.private_provider_config()?;
|
||||
|
||||
let run_cmd = RunCmd {
|
||||
@@ -412,7 +411,6 @@ impl Configuration {
|
||||
serve_light: !self.args.flag_no_serve_light,
|
||||
light: self.args.flag_light,
|
||||
no_persistent_txqueue: self.args.flag_no_persistent_txqueue,
|
||||
whisper: whisper_config,
|
||||
no_hardcoded_sync: self.args.flag_no_hardcoded_sync,
|
||||
max_round_blocks_to_import: self.args.arg_max_round_blocks_to_import,
|
||||
on_demand_response_time_window: self.args.arg_on_demand_response_time_window,
|
||||
@@ -1179,13 +1177,6 @@ impl Configuration {
|
||||
|
||||
settings
|
||||
}
|
||||
|
||||
fn whisper_config(&self) -> ::whisper::Config {
|
||||
::whisper::Config {
|
||||
enabled: self.args.flag_whisper,
|
||||
target_message_pool_size: self.args.arg_whisper_pool_size * 1024 * 1024,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn into_secretstore_service_contract_address(s: Option<&String>) -> Result<Option<SecretStoreContractAddress>, String> {
|
||||
@@ -1481,7 +1472,6 @@ mod tests {
|
||||
light: false,
|
||||
no_hardcoded_sync: false,
|
||||
no_persistent_txqueue: false,
|
||||
whisper: Default::default(),
|
||||
max_round_blocks_to_import: 12,
|
||||
on_demand_response_time_window: None,
|
||||
on_demand_request_backoff_start: None,
|
||||
|
||||
@@ -229,6 +229,16 @@ pub fn find_deprecated(args: &Args) -> Vec<Deprecated> {
|
||||
result.push(Deprecated::Removed("--ntp-servers"));
|
||||
}
|
||||
|
||||
// Removed in 2.7.
|
||||
|
||||
if args.flag_whisper {
|
||||
result.push(Deprecated::Removed("--whisper"));
|
||||
}
|
||||
|
||||
if args.arg_whisper_pool_size.is_some() {
|
||||
result.push(Deprecated::Removed("--whisper-pool-size"));
|
||||
}
|
||||
|
||||
result
|
||||
}
|
||||
|
||||
@@ -261,6 +271,8 @@ mod tests {
|
||||
args.flag_dapps_apis_all = true;
|
||||
args.flag_fast_and_loose = true;
|
||||
args.arg_ntp_servers = Some(Default::default());
|
||||
args.flag_whisper = true;
|
||||
args.arg_whisper_pool_size = Some(Default::default());
|
||||
args
|
||||
}), vec![
|
||||
Deprecated::DoesNothing("--warp"),
|
||||
@@ -282,6 +294,8 @@ mod tests {
|
||||
Deprecated::Replaced("--dapps-apis-all", "--jsonrpc-apis"),
|
||||
Deprecated::Removed("--fast-and-loose"),
|
||||
Deprecated::Removed("--ntp-servers"),
|
||||
Deprecated::Removed("--whisper"),
|
||||
Deprecated::Removed("--whisper-pool-size"),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,6 @@ extern crate parity_rpc;
|
||||
extern crate parity_runtime;
|
||||
extern crate parity_updater as updater;
|
||||
extern crate parity_version;
|
||||
extern crate parity_whisper;
|
||||
extern crate registrar;
|
||||
|
||||
#[macro_use]
|
||||
@@ -111,7 +110,6 @@ mod signer;
|
||||
mod snapshot;
|
||||
mod upgrade;
|
||||
mod user_defaults;
|
||||
mod whisper;
|
||||
mod db;
|
||||
|
||||
use std::fs::File;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
use std::sync::{Arc, mpsc};
|
||||
|
||||
use ethcore::client::BlockChainClient;
|
||||
use sync::{self, AttachedProtocol, SyncConfig, NetworkConfiguration, Params, ConnectionFilter};
|
||||
use sync::{self, SyncConfig, NetworkConfiguration, Params, ConnectionFilter};
|
||||
use ethcore::snapshot::SnapshotService;
|
||||
use light::Provider;
|
||||
use parity_runtime::Executor;
|
||||
@@ -42,7 +42,6 @@ pub fn sync(
|
||||
private_tx_handler: Option<Arc<PrivateTxHandler>>,
|
||||
provider: Arc<Provider>,
|
||||
_log_settings: &LogConfig,
|
||||
attached_protos: Vec<AttachedProtocol>,
|
||||
connection_filter: Option<Arc<ConnectionFilter>>,
|
||||
) -> Result<SyncModules, sync::Error> {
|
||||
let eth_sync = EthSync::new(Params {
|
||||
@@ -53,7 +52,6 @@ pub fn sync(
|
||||
snapshot_service,
|
||||
private_tx_handler,
|
||||
network_config,
|
||||
attached_protos,
|
||||
},
|
||||
connection_filter)?;
|
||||
|
||||
|
||||
@@ -66,12 +66,6 @@ pub enum Api {
|
||||
Rpc,
|
||||
/// Private transaction manager (Safe)
|
||||
Private,
|
||||
/// Whisper (Safe)
|
||||
// TODO: _if_ someone guesses someone else's key or filter IDs they can remove
|
||||
// BUT these are all ephemeral so it seems fine.
|
||||
Whisper,
|
||||
/// Whisper Pub-Sub (Safe but same concerns as above).
|
||||
WhisperPubSub,
|
||||
/// Parity PubSub - Generic Publish-Subscriber (Safety depends on other APIs exposed).
|
||||
ParityPubSub,
|
||||
/// Parity Accounts extensions (UNSAFE: Passwords, Side Effects (new account))
|
||||
@@ -85,6 +79,8 @@ pub enum Api {
|
||||
Debug,
|
||||
/// Parity Transactions pool PubSub
|
||||
ParityTransactionsPool,
|
||||
/// Deprecated api
|
||||
Deprecated,
|
||||
}
|
||||
|
||||
impl FromStr for Api {
|
||||
@@ -106,12 +102,11 @@ impl FromStr for Api {
|
||||
"pubsub" => Ok(EthPubSub),
|
||||
"rpc" => Ok(Rpc),
|
||||
"secretstore" => Ok(SecretStore),
|
||||
"shh" => Ok(Whisper),
|
||||
"shh_pubsub" => Ok(WhisperPubSub),
|
||||
"signer" => Ok(Signer),
|
||||
"traces" => Ok(Traces),
|
||||
"web3" => Ok(Web3),
|
||||
"parity_transactions_pool" => Ok(ParityTransactionsPool),
|
||||
"shh" | "shh_pubsub" => Ok(Deprecated),
|
||||
api => Err(format!("Unknown api: {}", api)),
|
||||
}
|
||||
}
|
||||
@@ -193,9 +188,10 @@ fn to_modules(apis: &HashSet<Api>) -> BTreeMap<String, String> {
|
||||
Api::Signer => ("signer", "1.0"),
|
||||
Api::Traces => ("traces", "1.0"),
|
||||
Api::Web3 => ("web3", "1.0"),
|
||||
Api::Whisper => ("shh", "1.0"),
|
||||
Api::WhisperPubSub => ("shh_pubsub", "1.0"),
|
||||
Api::ParityTransactionsPool => ("parity_transactions_pool", "1.0"),
|
||||
Api::Deprecated => {
|
||||
continue;
|
||||
}
|
||||
};
|
||||
modules.insert(name.into(), version.into());
|
||||
}
|
||||
@@ -255,7 +251,6 @@ pub struct FullDependencies {
|
||||
pub ws_address: Option<Host>,
|
||||
pub fetch: FetchClient,
|
||||
pub executor: Executor,
|
||||
pub whisper_rpc: Option<::whisper::RpcFactory>,
|
||||
pub gas_price_percentile: usize,
|
||||
pub poll_lifetime: u32,
|
||||
pub allow_missing_blocks: bool,
|
||||
@@ -449,28 +444,13 @@ impl FullDependencies {
|
||||
#[cfg(feature = "accounts")]
|
||||
handler.extend_with(SecretStoreClient::new(&self.accounts).to_delegate());
|
||||
}
|
||||
Api::Whisper => {
|
||||
if let Some(ref whisper_rpc) = self.whisper_rpc {
|
||||
let whisper = whisper_rpc.make_handler(self.net.clone());
|
||||
handler.extend_with(::parity_whisper::rpc::Whisper::to_delegate(whisper));
|
||||
}
|
||||
}
|
||||
Api::WhisperPubSub => {
|
||||
if !for_generic_pubsub {
|
||||
if let Some(ref whisper_rpc) = self.whisper_rpc {
|
||||
let whisper = whisper_rpc.make_handler(self.net.clone());
|
||||
handler.extend_with(::parity_whisper::rpc::WhisperPubSub::to_delegate(
|
||||
whisper,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
Api::Private => {
|
||||
handler.extend_with(
|
||||
PrivateClient::new(self.private_tx_service.as_ref().map(|p| p.provider()))
|
||||
.to_delegate(),
|
||||
);
|
||||
}
|
||||
Api::Deprecated => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -517,7 +497,6 @@ pub struct LightDependencies<T> {
|
||||
pub geth_compatibility: bool,
|
||||
pub experimental_rpcs: bool,
|
||||
pub executor: Executor,
|
||||
pub whisper_rpc: Option<::whisper::RpcFactory>,
|
||||
pub private_tx_service: Option<Arc<PrivateTransactionManager>>,
|
||||
pub gas_price_percentile: usize,
|
||||
pub poll_lifetime: u32,
|
||||
@@ -686,26 +665,13 @@ impl<C: LightChainClient + 'static> LightDependencies<C> {
|
||||
#[cfg(feature = "accounts")]
|
||||
handler.extend_with(SecretStoreClient::new(&self.accounts).to_delegate());
|
||||
}
|
||||
Api::Whisper => {
|
||||
if let Some(ref whisper_rpc) = self.whisper_rpc {
|
||||
let whisper = whisper_rpc.make_handler(self.net.clone());
|
||||
handler.extend_with(::parity_whisper::rpc::Whisper::to_delegate(whisper));
|
||||
}
|
||||
}
|
||||
Api::WhisperPubSub => {
|
||||
if let Some(ref whisper_rpc) = self.whisper_rpc {
|
||||
let whisper = whisper_rpc.make_handler(self.net.clone());
|
||||
handler.extend_with(::parity_whisper::rpc::WhisperPubSub::to_delegate(
|
||||
whisper,
|
||||
));
|
||||
}
|
||||
}
|
||||
Api::Private => {
|
||||
if let Some(ref tx_manager) = self.private_tx_service {
|
||||
let private_tx_service = Some(tx_manager.clone());
|
||||
handler.extend_with(PrivateClient::new(private_tx_service).to_delegate());
|
||||
}
|
||||
}
|
||||
Api::Deprecated => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -740,8 +706,6 @@ impl ApiSet {
|
||||
Api::EthPubSub,
|
||||
Api::Parity,
|
||||
Api::Rpc,
|
||||
Api::Whisper,
|
||||
Api::WhisperPubSub,
|
||||
Api::Private,
|
||||
]
|
||||
.into_iter()
|
||||
@@ -749,7 +713,10 @@ impl ApiSet {
|
||||
.collect();
|
||||
|
||||
match *self {
|
||||
ApiSet::List(ref apis) => apis.clone(),
|
||||
ApiSet::List(ref apis) => apis.into_iter()
|
||||
.filter(|api| *api != &Api::Deprecated)
|
||||
.cloned()
|
||||
.collect(),
|
||||
ApiSet::UnsafeContext => {
|
||||
public_list.insert(Api::Traces);
|
||||
public_list.insert(Api::ParityPubSub);
|
||||
@@ -810,8 +777,6 @@ mod test {
|
||||
assert_eq!(Api::Rpc, "rpc".parse().unwrap());
|
||||
assert_eq!(Api::SecretStore, "secretstore".parse().unwrap());
|
||||
assert_eq!(Api::Private, "private".parse().unwrap());
|
||||
assert_eq!(Api::Whisper, "shh".parse().unwrap());
|
||||
assert_eq!(Api::WhisperPubSub, "shh_pubsub".parse().unwrap());
|
||||
assert_eq!(Api::ParityTransactionsPool, "parity_transactions_pool".parse().unwrap());
|
||||
assert!("rp".parse::<Api>().is_err());
|
||||
}
|
||||
@@ -841,8 +806,6 @@ mod test {
|
||||
Api::ParityPubSub,
|
||||
Api::Traces,
|
||||
Api::Rpc,
|
||||
Api::Whisper,
|
||||
Api::WhisperPubSub,
|
||||
Api::Private,
|
||||
Api::ParityTransactionsPool,
|
||||
].into_iter()
|
||||
@@ -862,8 +825,6 @@ mod test {
|
||||
Api::ParityPubSub,
|
||||
Api::Traces,
|
||||
Api::Rpc,
|
||||
Api::Whisper,
|
||||
Api::WhisperPubSub,
|
||||
Api::Private,
|
||||
Api::ParityTransactionsPool,
|
||||
// semi-safe
|
||||
@@ -888,8 +849,6 @@ mod test {
|
||||
Api::Traces,
|
||||
Api::Rpc,
|
||||
Api::SecretStore,
|
||||
Api::Whisper,
|
||||
Api::WhisperPubSub,
|
||||
Api::ParityAccounts,
|
||||
Api::ParitySet,
|
||||
Api::Signer,
|
||||
@@ -918,8 +877,6 @@ mod test {
|
||||
Api::Traces,
|
||||
Api::Rpc,
|
||||
Api::SecretStore,
|
||||
Api::Whisper,
|
||||
Api::WhisperPubSub,
|
||||
Api::ParityAccounts,
|
||||
Api::ParitySet,
|
||||
Api::Signer,
|
||||
@@ -946,8 +903,6 @@ mod test {
|
||||
Api::ParityPubSub,
|
||||
Api::Traces,
|
||||
Api::Rpc,
|
||||
Api::Whisper,
|
||||
Api::WhisperPubSub,
|
||||
Api::Private,
|
||||
Api::ParityTransactionsPool,
|
||||
].into_iter()
|
||||
|
||||
@@ -130,7 +130,6 @@ pub struct RunCmd {
|
||||
pub serve_light: bool,
|
||||
pub light: bool,
|
||||
pub no_persistent_txqueue: bool,
|
||||
pub whisper: ::whisper::Config,
|
||||
pub no_hardcoded_sync: bool,
|
||||
pub max_round_blocks_to_import: usize,
|
||||
pub on_demand_response_time_window: Option<u64>,
|
||||
@@ -269,15 +268,6 @@ fn execute_light_impl<Cr>(cmd: RunCmd, logger: Arc<RotatingLogger>, on_client_rq
|
||||
net_conf.boot_nodes = spec.nodes.clone();
|
||||
}
|
||||
|
||||
let mut attached_protos = Vec::new();
|
||||
let whisper_factory = if cmd.whisper.enabled {
|
||||
let whisper_factory = ::whisper::setup(cmd.whisper.target_message_pool_size, &mut attached_protos)
|
||||
.map_err(|e| format!("Failed to initialize whisper: {}", e))?;
|
||||
whisper_factory
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
// set network path.
|
||||
net_conf.net_config_path = Some(db_dirs.network_path().to_string_lossy().into_owned());
|
||||
let sync_params = LightSyncParams {
|
||||
@@ -286,7 +276,6 @@ fn execute_light_impl<Cr>(cmd: RunCmd, logger: Arc<RotatingLogger>, on_client_rq
|
||||
network_id: cmd.network_id.unwrap_or(spec.network_id()),
|
||||
subprotocol_name: sync::LIGHT_PROTOCOL,
|
||||
handlers: vec![on_demand.clone()],
|
||||
attached_protos: attached_protos,
|
||||
};
|
||||
let light_sync = LightSync::new(sync_params).map_err(|e| format!("Error starting network: {}", e))?;
|
||||
let light_sync = Arc::new(light_sync);
|
||||
@@ -326,7 +315,6 @@ fn execute_light_impl<Cr>(cmd: RunCmd, logger: Arc<RotatingLogger>, on_client_rq
|
||||
geth_compatibility: cmd.geth_compatibility,
|
||||
experimental_rpcs: cmd.experimental_rpcs,
|
||||
executor: runtime.executor(),
|
||||
whisper_rpc: whisper_factory,
|
||||
private_tx_service: None, //TODO: add this to client.
|
||||
gas_price_percentile: cmd.gas_price_percentile,
|
||||
poll_lifetime: cmd.poll_lifetime
|
||||
@@ -633,17 +621,6 @@ fn execute_impl<Cr, Rr>(cmd: RunCmd, logger: Arc<RotatingLogger>, on_client_rq:
|
||||
.map_err(|e| format!("Stratum start error: {:?}", e))?;
|
||||
}
|
||||
|
||||
let mut attached_protos = Vec::new();
|
||||
|
||||
let whisper_factory = if cmd.whisper.enabled {
|
||||
let whisper_factory = ::whisper::setup(cmd.whisper.target_message_pool_size, &mut attached_protos)
|
||||
.map_err(|e| format!("Failed to initialize whisper: {}", e))?;
|
||||
|
||||
whisper_factory
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let private_tx_sync: Option<Arc<PrivateTxHandler>> = match cmd.private_tx_enabled {
|
||||
true => Some(private_tx_service.clone() as Arc<PrivateTxHandler>),
|
||||
false => None,
|
||||
@@ -659,7 +636,6 @@ fn execute_impl<Cr, Rr>(cmd: RunCmd, logger: Arc<RotatingLogger>, on_client_rq:
|
||||
private_tx_sync,
|
||||
client.clone(),
|
||||
&cmd.logger_config,
|
||||
attached_protos,
|
||||
connection_filter.clone().map(|f| f as Arc<::sync::ConnectionFilter + 'static>),
|
||||
).map_err(|e| format!("Sync error: {}", e))?;
|
||||
|
||||
@@ -745,7 +721,6 @@ fn execute_impl<Cr, Rr>(cmd: RunCmd, logger: Arc<RotatingLogger>, on_client_rq:
|
||||
ws_address: cmd.ws_conf.address(),
|
||||
fetch: fetch.clone(),
|
||||
executor: runtime.executor(),
|
||||
whisper_rpc: whisper_factory,
|
||||
private_tx_service: Some(private_tx_service.clone()),
|
||||
gas_price_percentile: cmd.gas_price_percentile,
|
||||
poll_lifetime: cmd.poll_lifetime,
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Ethereum.
|
||||
|
||||
// Parity Ethereum 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 Ethereum 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 Ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::io;
|
||||
|
||||
use sync::{AttachedProtocol, ManageNetwork};
|
||||
use parity_rpc::Metadata;
|
||||
use parity_whisper::message::Message;
|
||||
use parity_whisper::net::{self as whisper_net, Network as WhisperNetwork};
|
||||
use parity_whisper::rpc::{WhisperClient, PoolHandle, FilterManager};
|
||||
|
||||
/// Whisper config.
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct Config {
|
||||
pub enabled: bool,
|
||||
pub target_message_pool_size: usize,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
fn default() -> Self {
|
||||
Config {
|
||||
enabled: false,
|
||||
target_message_pool_size: 10 * 1024 * 1024,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Standard pool handle.
|
||||
pub struct NetPoolHandle {
|
||||
/// Pool handle.
|
||||
handle: Arc<WhisperNetwork<Arc<FilterManager>>>,
|
||||
/// Network manager.
|
||||
net: Arc<ManageNetwork>,
|
||||
}
|
||||
|
||||
impl PoolHandle for NetPoolHandle {
|
||||
fn relay(&self, message: Message) -> bool {
|
||||
let mut res = false;
|
||||
let mut message = Some(message);
|
||||
self.net.with_proto_context(whisper_net::PROTOCOL_ID, &mut |ctx| {
|
||||
if let Some(message) = message.take() {
|
||||
res = self.handle.post_message(message, ctx);
|
||||
}
|
||||
});
|
||||
res
|
||||
}
|
||||
|
||||
fn pool_status(&self) -> whisper_net::PoolStatus {
|
||||
self.handle.pool_status()
|
||||
}
|
||||
}
|
||||
|
||||
/// Factory for standard whisper RPC.
|
||||
pub struct RpcFactory {
|
||||
net: Arc<WhisperNetwork<Arc<FilterManager>>>,
|
||||
manager: Arc<FilterManager>,
|
||||
}
|
||||
|
||||
impl RpcFactory {
|
||||
pub fn make_handler(&self, net: Arc<ManageNetwork>) -> WhisperClient<NetPoolHandle, Metadata> {
|
||||
let handle = NetPoolHandle { handle: self.net.clone(), net: net };
|
||||
WhisperClient::new(handle, self.manager.clone())
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets up whisper protocol and RPC handler.
|
||||
///
|
||||
/// Will target the given pool size.
|
||||
#[cfg(not(feature = "ipc"))]
|
||||
pub fn setup(target_pool_size: usize, protos: &mut Vec<AttachedProtocol>)
|
||||
-> io::Result<Option<RpcFactory>>
|
||||
{
|
||||
let manager = Arc::new(FilterManager::new()?);
|
||||
let net = Arc::new(WhisperNetwork::new(target_pool_size, manager.clone()));
|
||||
|
||||
protos.push(AttachedProtocol {
|
||||
handler: net.clone() as Arc<_>,
|
||||
versions: whisper_net::SUPPORTED_VERSIONS,
|
||||
protocol_id: whisper_net::PROTOCOL_ID,
|
||||
});
|
||||
|
||||
// parity-only extensions to whisper.
|
||||
protos.push(AttachedProtocol {
|
||||
handler: Arc::new(whisper_net::ParityExtensions),
|
||||
versions: whisper_net::SUPPORTED_VERSIONS,
|
||||
protocol_id: whisper_net::PARITY_PROTOCOL_ID,
|
||||
});
|
||||
|
||||
let factory = RpcFactory { net: net, manager: manager };
|
||||
|
||||
Ok(Some(factory))
|
||||
}
|
||||
|
||||
// TODO: make it possible to attach generic protocols in IPC.
|
||||
#[cfg(feature = "ipc")]
|
||||
pub fn setup(_target_pool_size: usize, _protos: &mut Vec<AttachedProtocol>)
|
||||
-> io::Result<Option<RpcFactory>>
|
||||
{
|
||||
Ok(None)
|
||||
}
|
||||
Reference in New Issue
Block a user