Rewriting webapps to use hyper-mio branch

This commit is contained in:
Tomasz Drwięga
2016-04-14 20:38:48 +02:00
parent 9892e43c4e
commit f81914351d
13 changed files with 532 additions and 232 deletions

View File

@@ -69,7 +69,7 @@ use number_prefix::{binary_prefix, Standalone, Prefixed};
#[cfg(feature = "rpc")]
use rpc::Server as RpcServer;
#[cfg(feature = "webapp")]
use webapp::Listening as WebappServer;
use webapp::Server as WebappServer;
mod price_info;
mod upgrade;
@@ -342,12 +342,12 @@ fn setup_webapp_server(
sync: Arc<EthSync>,
secret_store: Arc<AccountService>,
miner: Arc<Miner>,
url: &str,
url: &SocketAddr,
auth: Option<(String, String)>,
) -> WebappServer {
use rpc::v1::*;
let server = webapp::WebappServer::new();
let server = webapp::ServerBuilder::new();
server.add_delegate(Web3Client::new().to_delegate());
server.add_delegate(NetClient::new(&sync).to_delegate());
server.add_delegate(EthClient::new(&client, &sync, &secret_store, &miner).to_delegate());
@@ -356,14 +356,14 @@ fn setup_webapp_server(
server.add_delegate(EthcoreClient::new(&miner).to_delegate());
let start_result = match auth {
None => {
server.start_unsecure_http(url, ::num_cpus::get())
server.start_unsecure_http(url)
},
Some((username, password)) => {
server.start_basic_auth_http(url, ::num_cpus::get(), &username, &password)
server.start_basic_auth_http(url, &username, &password)
},
};
match start_result {
Err(webapp::WebappServerError::IoError(err)) => die_with_io_error(err),
Err(webapp::ServerError::IoError(err)) => die_with_io_error(err),
Err(e) => die!("{:?}", e),
Ok(handle) => handle,
}
@@ -379,7 +379,7 @@ fn setup_rpc_server(
_sync: Arc<EthSync>,
_secret_store: Arc<AccountService>,
_miner: Arc<Miner>,
_url: &str,
_url: &SocketAddr,
_cors_domain: &str,
_apis: Vec<&str>,
) -> ! {
@@ -395,7 +395,7 @@ fn setup_webapp_server(
_sync: Arc<EthSync>,
_secret_store: Arc<AccountService>,
_miner: Arc<Miner>,
_url: &str,
_url: &SocketAddr,
_auth: Option<(String, String)>,
) -> ! {
die!("Your Parity version has been compiled without WebApps support.")
@@ -736,6 +736,7 @@ impl Configuration {
},
self.args.flag_webapp_port
);
let addr = SocketAddr::from_str(&url).unwrap_or_else(|_| die!("{}: Invalid Webapps listen host/port given.", url));
let auth = self.args.flag_webapp_user.as_ref().map(|username| {
let password = self.args.flag_webapp_pass.as_ref().map_or_else(|| {
use rpassword::read_password;
@@ -752,7 +753,7 @@ impl Configuration {
sync.clone(),
account_service.clone(),
miner.clone(),
&url,
&addr,
auth,
))
} else {