diff --git a/Cargo.toml b/Cargo.toml index 55fb2440..933e6930 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,7 @@ git = "https://github.com/apoelstra/bitcoin-secp256k1-rs.git" [dependencies] byteorder = "*" +num_cpus = "*" rand = "*" rust-crypto = "*" rustc-serialize = "*" diff --git a/src/blockdata/blockchain.rs b/src/blockdata/blockchain.rs index b7d02a89..cbeacb46 100644 --- a/src/blockdata/blockchain.rs +++ b/src/blockdata/blockchain.rs @@ -23,7 +23,7 @@ //! use std::num::Zero; -use std::kinds::marker; +use std::marker; use blockdata::block::{Block, BlockHeader}; use blockdata::transaction::Transaction; diff --git a/src/blockdata/utxoset.rs b/src/blockdata/utxoset.rs index 93c3b5d4..4966c0d7 100644 --- a/src/blockdata/utxoset.rs +++ b/src/blockdata/utxoset.rs @@ -20,10 +20,10 @@ use std::cmp; use std::collections::HashMap; -use std::collections::hashmap::Entries; +use std::collections::hash::map::Iter; use std::default::Default; use std::mem; -use std::os::num_cpus; +use num_cpus; use std::sync::Future; use blockdata::transaction::{Transaction, TxOut}; @@ -69,7 +69,7 @@ impl_consensus_encoding!(UtxoNode, height, outputs); /// An iterator over UTXOs pub struct UtxoIterator<'a> { - tx_iter: Entries<'a, Sha256dHash, UtxoNode>, + tx_iter: Iter<'a, Sha256dHash, UtxoNode>, current_key: Sha256dHash, current: Option<&'a UtxoNode>, tx_index: u32 @@ -261,7 +261,7 @@ impl UtxoSet { let mut future_vec = Vec::with_capacity(block.txdata.len() - 1); // skip the genesis since we don't validate this script. (TODO this might // be a consensus bug since we don't even check that the opcodes make sense.) - let n_threads = cmp::min(block.txdata.len() - 1, num_cpus()); + let n_threads = cmp::min(block.txdata.len() - 1, num_cpus::get()); for j in range(0, n_threads) { let n_elems = block.txdata.len() - 1; let start = 1 + j * n_elems / n_threads; diff --git a/src/lib.rs b/src/lib.rs index f13975fa..ab4e1a7a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -46,6 +46,7 @@ extern crate alloc; extern crate byteorder; extern crate collections; extern crate core; +extern crate num_cpus; extern crate rand; extern crate rustc_serialize as serialize; extern crate test; diff --git a/src/util/patricia_tree.rs b/src/util/patricia_tree.rs index 9c0ef214..16e270c9 100644 --- a/src/util/patricia_tree.rs +++ b/src/util/patricia_tree.rs @@ -22,7 +22,7 @@ use core::fmt::Debug; use core::cmp; -use std::kinds::marker; +use std::marker; use std::num::{Zero, One}; use network::encodable::{ConsensusDecodable, ConsensusEncodable}; diff --git a/src/util/thinvec.rs b/src/util/thinvec.rs index 7c671c5a..d3afa128 100644 --- a/src/util/thinvec.rs +++ b/src/util/thinvec.rs @@ -21,7 +21,7 @@ use alloc::heap::{allocate, reallocate, deallocate}; use std::raw; -use std::slice::{Iter, MutIter}; +use std::slice::{Iter, IterMut}; use std::{fmt, mem, ptr}; use std::u32; @@ -69,7 +69,7 @@ impl ThinVec { /// Mutable iterator over elements of the vector #[inline] - pub fn iter_mut<'a>(&'a mut self) -> MutIter<'a, T> { + pub fn iter_mut<'a>(&'a mut self) -> IterMut<'a, T> { self.as_mut_slice().iter_mut() }