diff --git a/Cargo.lock b/Cargo.lock
index eae4823f6..ffb4fc12b 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -13,6 +13,7 @@ dependencies = [
"ethcore-devtools 1.3.0",
"ethcore-ipc 1.3.0",
"ethcore-ipc-codegen 1.3.0",
+ "ethcore-ipc-hypervisor 1.2.0",
"ethcore-ipc-nano 1.3.0",
"ethcore-rpc 1.3.0",
"ethcore-signer 1.3.0",
@@ -315,6 +316,19 @@ dependencies = [
"syntex_syntax 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[[package]]
+name = "ethcore-ipc-hypervisor"
+version = "1.2.0"
+dependencies = [
+ "ethcore-ipc 1.3.0",
+ "ethcore-ipc-codegen 1.3.0",
+ "ethcore-ipc-nano 1.3.0",
+ "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "nanomsg 0.5.1 (git+https://github.com/ethcore/nanomsg.rs.git)",
+ "semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syntex 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
[[package]]
name = "ethcore-ipc-nano"
version = "1.3.0"
diff --git a/Cargo.toml b/Cargo.toml
index e49c3efc5..02b7070f7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -33,6 +33,7 @@ ethcore-dapps = { path = "dapps", optional = true }
semver = "0.2"
ethcore-ipc-nano = { path = "ipc/nano" }
ethcore-ipc = { path = "ipc/rpc" }
+ethcore-ipc-hypervisor = { path = "ipc/hypervisor" }
json-ipc-server = { git = "https://github.com/ethcore/json-ipc-server.git" }
ansi_term = "0.7"
diff --git a/build.rs b/build.rs
index 25764f4be..41b9a1b3e 100644
--- a/build.rs
+++ b/build.rs
@@ -15,35 +15,11 @@
// along with Parity. If not, see .
extern crate rustc_version;
-extern crate syntex;
-extern crate ethcore_ipc_codegen as codegen;
-use std::env;
-use std::path::Path;
use rustc_version::{version_meta, Channel};
fn main() {
if let Channel::Nightly = version_meta().channel {
println!("cargo:rustc-cfg=nightly");
}
-
- let out_dir = env::var_os("OUT_DIR").unwrap();
-
- // ipc pass
- {
- let src = Path::new("parity/hypervisor/service.rs.in");
- let dst = Path::new(&out_dir).join("hypervisor_service_ipc.rs");
- let mut registry = syntex::Registry::new();
- codegen::register(&mut registry);
- registry.expand("", &src, &dst).unwrap();
- }
-
- // serialization pass
- {
- let src = Path::new(&out_dir).join("hypervisor_service_ipc.rs");
- let dst = Path::new(&out_dir).join("hypervisor_service_cg.rs");
- let mut registry = syntex::Registry::new();
- codegen::register(&mut registry);
- registry.expand("", &src, &dst).unwrap();
- }
}
diff --git a/dapps/src/lib.rs b/dapps/src/lib.rs
index ccdf172ce..a94cf1bde 100644
--- a/dapps/src/lib.rs
+++ b/dapps/src/lib.rs
@@ -54,6 +54,7 @@ extern crate jsonrpc_core;
extern crate jsonrpc_http_server;
extern crate parity_dapps;
extern crate ethcore_rpc;
+extern crate ethcore_util;
extern crate mime_guess;
mod endpoint;
@@ -69,6 +70,7 @@ mod url;
use std::sync::{Arc, Mutex};
use std::net::SocketAddr;
use std::collections::HashMap;
+use ethcore_util::misc::Lockable;
use jsonrpc_core::{IoHandler, IoDelegate};
use router::auth::{Authorization, NoAuth, HttpBasicAuth};
use ethcore_rpc::Extendable;
@@ -151,7 +153,7 @@ impl Server {
/// Set callback for panics.
pub fn set_panic_handler(&self, handler: F) where F : Fn() -> () + Send + 'static {
- *self.panic_handler.lock().unwrap() = Some(Box::new(handler));
+ *self.panic_handler.locked() = Some(Box::new(handler));
}
}
diff --git a/db/src/database.rs b/db/src/database.rs
index d535f1f56..0ad02b783 100644
--- a/db/src/database.rs
+++ b/db/src/database.rs
@@ -17,8 +17,8 @@
//! Ethcore rocksdb ipc service
use traits::*;
-use rocksdb::{DB, Writable, WriteBatch, IteratorMode, DBIterator,
-IndexType, Options, DBCompactionStyle, BlockBasedOptions, Direction};
+use misc::RwLockable;
+use rocksdb::{DB, Writable, WriteBatch, IteratorMode, DBIterator, IndexType, Options, DBCompactionStyle, BlockBasedOptions, Direction};
use std::sync::{RwLock, Arc};
use std::convert::From;
use ipc::IpcConfig;
@@ -137,8 +137,8 @@ impl Database {
}
pub fn flush(&self) -> Result<(), Error> {
- let mut cache_lock = self.write_cache.write().unwrap();
- let db_lock = self.db.read().unwrap();
+ let mut cache_lock = self.write_cache.unwrapped_write();
+ let db_lock = self.db.unwrapped_read();
if db_lock.is_none() { return Ok(()); }
let db = db_lock.as_ref().unwrap();
@@ -147,8 +147,8 @@ impl Database {
}
pub fn flush_all(&self) -> Result<(), Error> {
- let mut cache_lock = self.write_cache.write().unwrap();
- let db_lock = self.db.read().unwrap();
+ let mut cache_lock = self.write_cache.unwrapped_write();
+ let db_lock = self.db.unwrapped_read();
if db_lock.is_none() { return Ok(()); }
let db = db_lock.as_ref().expect("we should have exited with Ok(()) on the previous step");
@@ -167,7 +167,7 @@ impl Drop for Database {
#[derive(Ipc)]
impl DatabaseService for Database {
fn open(&self, config: DatabaseConfig, path: String) -> Result<(), Error> {
- let mut db = self.db.write().unwrap();
+ let mut db = self.db.unwrapped_write();
if db.is_some() { return Err(Error::AlreadyOpen); }
let mut opts = Options::new();
@@ -194,7 +194,7 @@ impl DatabaseService for Database {
fn close(&self) -> Result<(), Error> {
try!(self.flush_all());
- let mut db = self.db.write().unwrap();
+ let mut db = self.db.unwrapped_write();
if db.is_none() { return Err(Error::IsClosed); }
*db = None;
@@ -202,19 +202,19 @@ impl DatabaseService for Database {
}
fn put(&self, key: &[u8], value: &[u8]) -> Result<(), Error> {
- let mut cache_lock = self.write_cache.write().unwrap();
+ let mut cache_lock = self.write_cache.unwrapped_write();
cache_lock.write(key.to_vec(), value.to_vec());
Ok(())
}
fn delete(&self, key: &[u8]) -> Result<(), Error> {
- let mut cache_lock = self.write_cache.write().unwrap();
+ let mut cache_lock = self.write_cache.unwrapped_write();
cache_lock.remove(key.to_vec());
Ok(())
}
fn write(&self, transaction: DBTransaction) -> Result<(), Error> {
- let mut cache_lock = self.write_cache.write().unwrap();
+ let mut cache_lock = self.write_cache.unwrapped_write();
let mut writes = transaction.writes.borrow_mut();
for kv in writes.drain(..) {
@@ -231,13 +231,13 @@ impl DatabaseService for Database {
fn get(&self, key: &[u8]) -> Result