diff --git a/Cargo.lock b/Cargo.lock
index d4e128d62..2a76a6004 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -888,6 +888,7 @@ dependencies = [
"base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
"secp256k1zkp 0.7.1 (git+https://github.com/mimblewimble/rust-secp256k1-zkp?tag=grin_integration_28)",
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/api/src/handlers.rs b/api/src/handlers.rs
index e2960ddf8..8d4c08dfb 100644
--- a/api/src/handlers.rs
+++ b/api/src/handlers.rs
@@ -14,7 +14,8 @@
use std::collections::HashMap;
use std::net::SocketAddr;
-use std::sync::{Arc, RwLock, Weak};
+use std::sync::{Arc, Weak};
+use util::RwLock;
use failure::ResultExt;
use futures::future::ok;
@@ -695,7 +696,7 @@ struct PoolInfoHandler {
impl Handler for PoolInfoHandler {
fn get(&self, _req: Request
) -> ResponseFuture {
let pool_arc = w(&self.tx_pool);
- let pool = pool_arc.read().unwrap();
+ let pool = pool_arc.read();
json_response(&PoolInfo {
pool_size: pool.total_size(),
@@ -753,7 +754,7 @@ impl PoolPushHandler {
);
// Push to tx pool.
- let mut tx_pool = pool_arc.write().unwrap();
+ let mut tx_pool = pool_arc.write();
let header = tx_pool.blockchain.chain_head().unwrap();
tx_pool
.add_to_pool(source, tx, !fluff, &header)
diff --git a/chain/src/chain.rs b/chain/src/chain.rs
index e36ea528c..e2a144e4d 100644
--- a/chain/src/chain.rs
+++ b/chain/src/chain.rs
@@ -18,8 +18,9 @@
use std::collections::HashMap;
use std::fs::File;
use std::sync::atomic::{AtomicUsize, Ordering};
-use std::sync::{Arc, RwLock};
+use std::sync::Arc;
use std::time::{Duration, Instant};
+use util::RwLock;
use lmdb;
use lru_cache::LruCache;
@@ -75,7 +76,7 @@ impl OrphanBlockPool {
}
fn len(&self) -> usize {
- let orphans = self.orphans.read().unwrap();
+ let orphans = self.orphans.read();
orphans.len()
}
@@ -84,8 +85,8 @@ impl OrphanBlockPool {
}
fn add(&self, orphan: Orphan) {
- let mut orphans = self.orphans.write().unwrap();
- let mut height_idx = self.height_idx.write().unwrap();
+ let mut orphans = self.orphans.write();
+ let mut height_idx = self.height_idx.write();
{
let height_hashes = height_idx
.entry(orphan.block.header.height)
@@ -125,15 +126,15 @@ impl OrphanBlockPool {
/// Get an orphan from the pool indexed by the hash of its parent, removing
/// it at the same time, preventing clone
fn remove_by_height(&self, height: &u64) -> Option> {
- let mut orphans = self.orphans.write().unwrap();
- let mut height_idx = self.height_idx.write().unwrap();
+ let mut orphans = self.orphans.write();
+ let mut height_idx = self.height_idx.write();
height_idx
.remove(height)
.map(|hs| hs.iter().filter_map(|h| orphans.remove(h)).collect())
}
pub fn contains(&self, hash: &Hash) -> bool {
- let orphans = self.orphans.read().unwrap();
+ let orphans = self.orphans.read();
orphans.contains_key(hash)
}
}
@@ -221,7 +222,7 @@ impl Chain {
fn process_block_single(&self, b: Block, opts: Options) -> Result