Skip to content

Commit

Permalink
Replace rustc_hex crate with hex
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Jan 25, 2020
1 parent e3aa0f4 commit 74afe53
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ publish = false
edition = "2018"

[dependencies]
hex = "0.4.0"
wasmi = "0.5"
rustc-hex = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_yaml = "0.8"
log = "0.4"
Expand Down
25 changes: 13 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
extern crate rustc_hex;
extern crate hex;
extern crate wasmi;
#[macro_use]
extern crate log;
extern crate env_logger;

use primitive_types::U256;
use rustc_hex::{FromHex, ToHex};
use serde::{Deserialize, Serialize};
use std::convert::{TryFrom, TryInto};
use std::env;
Expand Down Expand Up @@ -37,8 +36,8 @@ impl From<std::io::Error> for ScoutError {
}
}

impl From<rustc_hex::FromHexError> for ScoutError {
fn from(error: rustc_hex::FromHexError) -> Self {
impl From<hex::FromHexError> for ScoutError {
fn from(error: hex::FromHexError) -> Self {
ScoutError {
0: error.description().to_string(),
}
Expand Down Expand Up @@ -248,7 +247,7 @@ impl<'a> Externals for Runtime<'a> {
let tmp = memory
.get(ptr, length as usize)
.expect("expects reading from memory to succeed");
debug!("deposit: {}", tmp.to_hex());
debug!("deposit: {}", hex::encode(tmp.clone()));
self.deposits.push(tmp);

Ok(None)
Expand Down Expand Up @@ -286,7 +285,7 @@ impl<'a> Externals for Runtime<'a> {
memory
.get_into(ptr, &mut buf)
.expect("expects reading from memory to succeed");
debug!("print.hex: {}", buf.to_hex());
debug!("print.hex: {}", hex::encode(buf).clone());
Ok(None)
}
BIGNUM_ADD256_FUNC => {
Expand Down Expand Up @@ -552,7 +551,8 @@ impl Default for BLSPubKey {

impl fmt::Debug for BLSPubKey {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.0.to_hex())
unimplemented!()
// write!(f, "{}", hex::encode(self.0))
}
}

Expand All @@ -573,7 +573,8 @@ impl Default for BLSSignature {

impl fmt::Debug for BLSSignature {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.0.to_hex())
unimplemented!()
// write!(f, "{}", hex::encode(self.0))
}
}

Expand Down Expand Up @@ -653,7 +654,7 @@ pub struct ShardState {

impl fmt::Display for ShardBlockBody {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.data.to_hex())
write!(f, "{}", hex::encode(self.data.clone()))
}
}

Expand All @@ -672,7 +673,7 @@ impl fmt::Display for ShardState {
let states: Vec<String> = self
.exec_env_states
.iter()
.map(|x| x.bytes.to_hex())
.map(|state| hex::encode(state.bytes))
.collect();
write!(
f,
Expand Down Expand Up @@ -784,7 +785,7 @@ struct TestFile {
}

fn hex_to_slice(input: &str, output: &mut [u8]) -> Result<(), ScoutError> {
let tmp = input.from_hex()?;
let tmp = hex::decode(input)?;
if tmp.len() != output.len() {
return Err(ScoutError("Length mismatch from hex input".to_string()));
}
Expand Down Expand Up @@ -866,7 +867,7 @@ impl TryFrom<TestShardBlock> for ShardBlock {
Ok(ShardBlock {
env: input.env,
data: ShardBlockBody {
data: input.data.from_hex()?,
data: hex::decode(input.data)?,
},
})
}
Expand Down

0 comments on commit 74afe53

Please sign in to comment.