Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 21 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ regex = "1.0"
registrar = { path = "util/registrar" }
rlp = "0.4.0"
rpassword = "1.0"
rustc-hex = "1.0"
rustc-hex = "2.1.0"
semver = "0.9"
serde = "1.0"
serde_derive = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion accounts/ethkey/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ethkey = { path = "../" }
panic_hook = { path = "../../../util/panic-hook" }
parity-crypto = { version = "0.5.0", features = ["publickey"] }
parity-wordlist= "1.3.1"
rustc-hex = "1.0"
rustc-hex = "2.1.0"
serde = "1.0"
serde_derive = "1.0"
threadpool = "1.7"
Expand Down
2 changes: 1 addition & 1 deletion accounts/ethkey/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ fn execute<S, I>(command: I) -> Result<String, Error> where I: IntoIterator<Item
(Random.generate(), None)
}
} else if args.cmd_prefix {
let prefix = args.arg_prefix.from_hex()?;
let prefix: Vec<_> = args.arg_prefix.from_hex()?;
let brain = args.flag_brain;
in_threads(move || {
let iterations = 1024;
Expand Down
2 changes: 1 addition & 1 deletion accounts/ethstore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ethkey = { path = "../ethkey" }
serde = "1.0"
serde_json = "1.0"
serde_derive = "1.0"
rustc-hex = "1.0"
rustc-hex = "2.1.0"
tiny-keccak = "1.4"
time = "0.1.34"
parking_lot = "0.10.0"
Expand Down
2 changes: 1 addition & 1 deletion accounts/ethstore/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
docopt = "1.0"
env_logger = "0.5"
num_cpus = "1.6"
rustc-hex = "1.0"
rustc-hex = "2.1.0"
serde = "1.0"
serde_derive = "1.0"
parking_lot = "0.10.0"
Expand Down
2 changes: 1 addition & 1 deletion accounts/ethstore/src/json/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl<'a> Deserialize<'a> for Bytes {
impl Serialize for Bytes {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer {
serializer.serialize_str(&self.0.to_hex())
serializer.serialize_str(&self.0.to_hex::<String>())
}
}

Expand Down
7 changes: 4 additions & 3 deletions accounts/ethstore/src/json/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ macro_rules! impl_hash {

impl Serialize for $name {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer {
serializer.serialize_str(&self.0.to_hex())
where S: Serializer
{
serializer.serialize_str(&self.0.to_hex::<String>())
}
}

Expand Down Expand Up @@ -83,7 +84,7 @@ macro_rules! impl_hash {
type Err = Error;

fn from_str(value: &str) -> Result<Self, Self::Err> {
match value.from_hex() {
match value.from_hex::<Vec<u8>>() {
Ok(ref hex) if hex.len() == $size => {
let mut hash = [0u8; $size];
hash.clone_from_slice(hex);
Expand Down
3 changes: 2 additions & 1 deletion accounts/ethstore/src/json/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.

//! Universaly unique identifier.

use std::{fmt, str};
use rustc_hex::{ToHex, FromHex};
use serde::{Deserialize, Serialize, Deserializer, Serializer};
Expand Down Expand Up @@ -62,7 +63,7 @@ impl fmt::Display for Uuid {
}

fn copy_into(from: &str, into: &mut [u8]) -> Result<(), Error> {
let from = from.from_hex().map_err(|_| Error::InvalidUuid)?;
let from: Vec<u8> = from.from_hex().map_err(|_| Error::InvalidUuid)?;

if from.len() != into.len() {
return Err(Error::InvalidUuid);
Expand Down
3 changes: 2 additions & 1 deletion ethash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ static_assertions = "1.1.0"

[dev-dependencies]
criterion = "0.3"
rustc-hex = "1.0"
hex-literal = "0.2.1"
rustc-hex = "2.1.0"
serde_json = "1.0"
tempdir = "0.3"

Expand Down
14 changes: 8 additions & 6 deletions ethash/benches/progpow.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#[macro_use]
extern crate criterion;

#[macro_use]
extern crate hex_literal;

extern crate common_types;
extern crate ethash;
extern crate rustc_hex;
extern crate tempdir;
extern crate common_types;

use criterion::Criterion;
use ethash::progpow;

use tempdir::TempDir;
use rustc_hex::FromHex;
use ethash::NodeCacheBuilder;
use ethash::compute::light_compute;
use common_types::engines::OptimizeFor;
Expand All @@ -18,7 +20,7 @@ fn bench_hashimoto_light(c: &mut Criterion) {
let builder = NodeCacheBuilder::new(OptimizeFor::Memory, u64::max_value());
let tempdir = TempDir::new("").unwrap();
let light = builder.light(&tempdir.path(), 1);
let h = FromHex::from_hex("c9149cc0386e689d789a1c2f3d5d169a61a6218ed30e74414dc736e442ef3d1f").unwrap();
let h = hex!("c9149cc0386e689d789a1c2f3d5d169a61a6218ed30e74414dc736e442ef3d1f");
let mut hash = [0; 32];
hash.copy_from_slice(&h);

Expand All @@ -32,7 +34,7 @@ fn bench_progpow_light(c: &mut Criterion) {
let tempdir = TempDir::new("").unwrap();
let cache = builder.new_cache(tempdir.into_path(), 0);

let h = FromHex::from_hex("c9149cc0386e689d789a1c2f3d5d169a61a6218ed30e74414dc736e442ef3d1f").unwrap();
let h = hex!("c9149cc0386e689d789a1c2f3d5d169a61a6218ed30e74414dc736e442ef3d1f");
let mut hash = [0; 32];
hash.copy_from_slice(&h);

Expand All @@ -56,7 +58,7 @@ fn bench_progpow_optimal_light(c: &mut Criterion) {
let cache = builder.new_cache(tempdir.into_path(), 0);
let c_dag = progpow::generate_cdag(cache.as_ref());

let h = FromHex::from_hex("c9149cc0386e689d789a1c2f3d5d169a61a6218ed30e74414dc736e442ef3d1f").unwrap();
let h = hex!("c9149cc0386e689d789a1c2f3d5d169a61a6218ed30e74414dc736e442ef3d1f");
let mut hash = [0; 32];
hash.copy_from_slice(&h);

Expand Down
5 changes: 5 additions & 0 deletions ethash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ extern crate log;
#[macro_use]
extern crate static_assertions;

#[cfg(test)]
#[macro_use]
extern crate hex_literal;

#[cfg(test)]
extern crate rustc_hex;

Expand All @@ -35,6 +39,7 @@ extern crate serde_json;
#[cfg(test)]
extern crate tempdir;


#[cfg(feature = "bench")]
pub mod compute;
#[cfg(not(feature = "bench"))]
Expand Down
6 changes: 3 additions & 3 deletions ethash/src/progpow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ mod test {
use super::*;

fn h256(hex: &str) -> H256 {
let bytes = FromHex::from_hex(hex).unwrap();
let bytes: Vec<u8> = FromHex::from_hex(hex).unwrap();
let mut res = [0; 32];
res.copy_from_slice(&bytes);
res
Expand Down Expand Up @@ -549,8 +549,8 @@ mod test {
&c_dag,
);

let expected_digest = FromHex::from_hex("b3bad9ca6f7c566cf0377d1f8cce29d6516a96562c122d924626281ec948ef02").unwrap();
let expected_result = FromHex::from_hex("f4ac202715ded4136e72887c39e63a4738331c57fd9eb79f6ec421c281aa8743").unwrap();
let expected_digest = hex!("b3bad9ca6f7c566cf0377d1f8cce29d6516a96562c122d924626281ec948ef02");
let expected_result = hex!("f4ac202715ded4136e72887c39e63a4738331c57fd9eb79f6ec421c281aa8743");

assert_eq!(
digest.to_vec(),
Expand Down
Loading