Get rid of rustc_hex in favor of hex (#5370)

* Get rid of rustc_hex in favor of hex

* Use HexDisplay
This commit is contained in:
Stanislav Tkach
2020-03-24 12:48:23 +02:00
committed by GitHub
parent 5345407783
commit 4414d00082
10 changed files with 34 additions and 41 deletions
+1 -5
View File
@@ -3598,7 +3598,6 @@ dependencies = [
"pallet-utility",
"pallet-vesting",
"parity-scale-codec",
"rustc-hex",
"serde",
"sp-api",
"sp-authority-discovery",
@@ -6291,6 +6290,7 @@ dependencies = [
"futures 0.3.4",
"futures-timer 3.0.2",
"futures_codec",
"hex",
"libp2p",
"linked-hash-map",
"linked_hash_set",
@@ -6304,7 +6304,6 @@ dependencies = [
"prost-build",
"quickcheck",
"rand 0.7.3",
"rustc-hex",
"sc-block-builder",
"sc-client",
"sc-client-api",
@@ -6430,7 +6429,6 @@ dependencies = [
"log 0.4.8",
"parity-scale-codec",
"parking_lot 0.10.0",
"rustc-hex",
"sc-block-builder",
"sc-client",
"sc-client-api",
@@ -7249,7 +7247,6 @@ dependencies = [
"primitive-types",
"rand 0.7.3",
"regex",
"rustc-hex",
"schnorrkel",
"serde",
"serde_json",
@@ -7746,7 +7743,6 @@ dependencies = [
"parity-scale-codec",
"rand 0.7.3",
"rpassword",
"rustc-hex",
"sc-rpc",
"serde_json",
"sp-core",
-2
View File
@@ -13,7 +13,6 @@ repository = "https://github.com/paritytech/substrate/"
# third-party dependencies
codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] }
integer-sqrt = { version = "0.1.2" }
rustc-hex = { version = "2.0", optional = true }
serde = { version = "1.0.102", optional = true }
# primitives
@@ -108,7 +107,6 @@ std = [
"sp-core/std",
"pallet-randomness-collective-flip/std",
"sp-std/std",
"rustc-hex",
"serde",
"pallet-session/std",
"sp-api/std",
-1
View File
@@ -68,7 +68,6 @@ use impls::{CurrencyToVoteHandler, Author, LinearWeightToFee, TargetedFeeAdjustm
/// Constant values used within the runtime.
pub mod constants;
use constants::{time::*, currency::*};
use frame_system::Trait;
// Make the WASM binary available.
#[cfg(feature = "std")]
-1
View File
@@ -16,7 +16,6 @@ sp-runtime = { version = "2.0.0-alpha.4", path = "../../../primitives/runtime" }
rand = "0.7.2"
clap = "2.33.0"
tiny-bip39 = "0.7"
rustc-hex = "2.0.1"
substrate-bip39 = "0.4.1"
hex = "0.4.0"
hex-literal = "0.2.1"
+2 -2
View File
@@ -648,7 +648,7 @@ fn read_pair<C: Crypto>(
}
fn format_signature<C: Crypto>(signature: &SignatureOf<C>) -> String {
format!("{}", hex::encode(signature))
format!("{}", HexDisplay::from(&signature.as_ref()))
}
fn format_seed<C: Crypto>(seed: SeedOf<C>) -> String {
@@ -711,7 +711,7 @@ fn create_extrinsic<C: Crypto>(
}
fn print_extrinsic(extrinsic: UncheckedExtrinsic) {
println!("0x{}", hex::encode(&extrinsic.encode()));
println!("0x{}", HexDisplay::from(&extrinsic.encode()));
}
fn print_usage(matches: &ArgMatches) {
+1 -1
View File
@@ -35,7 +35,7 @@ nohash-hasher = "0.2.0"
parking_lot = "0.10.0"
prost = "0.6.1"
rand = "0.7.2"
rustc-hex = "2.0.1"
hex = "0.4.0"
sc-block-builder = { version = "0.8.0-alpha.4", path = "../block-builder" }
sc-client = { version = "0.8.0-alpha.4", path = "../" }
sc-client-api = { version = "2.0.0-alpha.4", path = "../api" }
+17 -15
View File
@@ -23,7 +23,10 @@ use libp2p::{Multiaddr, PeerId};
use libp2p::core::{ConnectedPoint, nodes::listeners::ListenerId};
use libp2p::swarm::{ProtocolsHandler, IntoProtocolsHandler};
use libp2p::swarm::{NetworkBehaviour, NetworkBehaviourAction, PollParameters};
use sp_core::storage::{StorageKey, ChildInfo};
use sp_core::{
storage::{StorageKey, ChildInfo},
hexdisplay::HexDisplay
};
use sp_consensus::{
BlockOrigin,
block_validation::BlockAnnounceValidator,
@@ -42,7 +45,6 @@ use prometheus_endpoint::{Registry, Gauge, GaugeVec, PrometheusError, Opts, regi
use sync::{ChainSync, SyncState};
use crate::service::{TransactionPool, ExHashT};
use crate::config::{BoxFinalityProofRequestBuilder, Roles};
use rustc_hex::ToHex;
use std::borrow::Cow;
use std::collections::{BTreeMap, HashMap, HashSet};
use std::sync::Arc;
@@ -1553,11 +1555,11 @@ impl<B: BlockT, H: ExHashT> Protocol<B, H> {
}
let keys_str = || match request.keys.len() {
1 => request.keys[0].to_hex::<String>(),
1 => HexDisplay::from(&request.keys[0]).to_string(),
_ => format!(
"{}..{}",
request.keys[0].to_hex::<String>(),
request.keys[request.keys.len() - 1].to_hex::<String>(),
HexDisplay::from(&request.keys[0]),
HexDisplay::from(&request.keys[request.keys.len() - 1]),
),
};
@@ -1601,16 +1603,16 @@ impl<B: BlockT, H: ExHashT> Protocol<B, H> {
}
let keys_str = || match request.keys.len() {
1 => request.keys[0].to_hex::<String>(),
1 => HexDisplay::from(&request.keys[0]).to_string(),
_ => format!(
"{}..{}",
request.keys[0].to_hex::<String>(),
request.keys[request.keys.len() - 1].to_hex::<String>(),
HexDisplay::from(&request.keys[0]),
HexDisplay::from(&request.keys[request.keys.len() - 1]),
),
};
trace!(target: "sync", "Remote read child request {} from {} ({} {} at {})",
request.id, who, request.storage_key.to_hex::<String>(), keys_str(), request.block);
request.id, who, HexDisplay::from(&request.storage_key), keys_str(), request.block);
let proof = if let Some(child_info) = ChildInfo::resolve_child_info(request.child_type, &request.child_info[..]) {
match self.context_data.chain.read_child_proof(
&BlockId::Hash(request.block),
@@ -1623,7 +1625,7 @@ impl<B: BlockT, H: ExHashT> Protocol<B, H> {
trace!(target: "sync", "Remote read child request {} from {} ({} {} at {}) failed with: {}",
request.id,
who,
request.storage_key.to_hex::<String>(),
HexDisplay::from(&request.storage_key),
keys_str(),
request.block,
error
@@ -1635,7 +1637,7 @@ impl<B: BlockT, H: ExHashT> Protocol<B, H> {
trace!(target: "sync", "Remote read child request {} from {} ({} {} at {}) failed with: {}",
request.id,
who,
request.storage_key.to_hex::<String>(),
HexDisplay::from(&request.storage_key),
keys_str(),
request.block,
"invalid child info and type",
@@ -1714,9 +1716,9 @@ impl<B: BlockT, H: ExHashT> Protocol<B, H> {
request.id,
who,
if let Some(sk) = request.storage_key.as_ref() {
format!("{} : {}", sk.to_hex::<String>(), request.key.to_hex::<String>())
format!("{} : {}", HexDisplay::from(sk), HexDisplay::from(&request.key))
} else {
request.key.to_hex::<String>()
HexDisplay::from(&request.key).to_string()
},
request.first,
request.last
@@ -1737,9 +1739,9 @@ impl<B: BlockT, H: ExHashT> Protocol<B, H> {
request.id,
who,
if let Some(sk) = storage_key {
format!("{} : {}", sk.0.to_hex::<String>(), key.0.to_hex::<String>())
format!("{} : {}", HexDisplay::from(&sk.0), HexDisplay::from(&key.0))
} else {
key.0.to_hex::<String>()
HexDisplay::from(&key.0).to_string()
},
request.first,
request.last,
@@ -51,11 +51,13 @@ use libp2p::{
};
use nohash_hasher::IntMap;
use prost::Message;
use rustc_hex::ToHex;
use sc_client::light::fetcher;
use sc_client_api::StorageProof;
use sc_peerset::ReputationChange;
use sp_core::storage::{ChildInfo, StorageKey};
use sp_core::{
storage::{ChildInfo, StorageKey},
hexdisplay::HexDisplay,
};
use sp_blockchain::{Error as ClientError};
use sp_runtime::{
traits::{Block, Header, NumberFor, Zero},
@@ -504,7 +506,7 @@ where
log::trace!("remote read child request from {} ({} {} at {:?})",
peer,
request.storage_key.to_hex::<String>(),
HexDisplay::from(&request.storage_key),
fmt_keys(request.keys.first(), request.keys.last()),
request.block);
@@ -522,7 +524,7 @@ where
Err(error) => {
log::trace!("remote read child request from {} ({} {} at {:?}) failed with: {}",
peer,
request.storage_key.to_hex::<String>(),
HexDisplay::from(&request.storage_key),
fmt_keys(request.keys.first(), request.keys.last()),
request.block,
error);
@@ -532,7 +534,7 @@ where
} else {
log::trace!("remote read child request from {} ({} {} at {:?}) failed with: {}",
peer,
request.storage_key.to_hex::<String>(),
HexDisplay::from(&request.storage_key),
fmt_keys(request.keys.first(), request.keys.last()),
request.block,
"invalid child info and type"
@@ -585,9 +587,9 @@ where
log::trace!("remote changes proof request from {} for key {} ({:?}..{:?})",
peer,
if !request.storage_key.is_empty() {
format!("{} : {}", request.storage_key.to_hex::<String>(), request.key.to_hex::<String>())
format!("{} : {}", HexDisplay::from(&request.storage_key), HexDisplay::from(&request.key))
} else {
request.key.to_hex::<String>()
HexDisplay::from(&request.key).to_string()
},
request.first,
request.last);
@@ -610,9 +612,9 @@ where
log::trace!("remote changes proof request from {} for key {} ({:?}..{:?}) failed with: {}",
peer,
if let Some(sk) = storage_key {
format!("{} : {}", sk.0.to_hex::<String>(), key.0.to_hex::<String>())
format!("{} : {}", HexDisplay::from(&sk.0), HexDisplay::from(&key.0))
} else {
key.0.to_hex::<String>()
HexDisplay::from(&key.0).to_string()
},
request.first,
request.last,
@@ -1089,9 +1091,9 @@ where
fn fmt_keys(first: Option<&Vec<u8>>, last: Option<&Vec<u8>>) -> String {
if let (Some(first), Some(last)) = (first, last) {
if first == last {
first.to_hex::<String>()
HexDisplay::from(first).to_string()
} else {
format!("{}..{}", first.to_hex::<String>(), last.to_hex::<String>())
format!("{}..{}", HexDisplay::from(first), HexDisplay::from(last))
}
} else {
String::from("n/a")
-1
View File
@@ -38,7 +38,6 @@ parking_lot = "0.10.0"
assert_matches = "1.3.0"
futures01 = { package = "futures", version = "0.1.29" }
sc-network = { version = "0.8.0-alpha.4", path = "../network" }
rustc-hex = "2.0.1"
sp-io = { version = "2.0.0-alpha.4", path = "../../primitives/io" }
substrate-test-runtime-client = { version = "2.0.0-dev", path = "../../test-utils/runtime/client" }
tokio = "0.1.22"
-2
View File
@@ -12,7 +12,6 @@ documentation = "https://docs.rs/sp-core"
[dependencies]
sp-std = { version = "2.0.0-alpha.4", default-features = false, path = "../std" }
codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] }
rustc-hex = { version = "2.0.1", default-features = false }
log = { version = "0.4.8", default-features = false }
serde = { version = "1.0.101", optional = true, features = ["derive"] }
byteorder = { version = "1.3.2", default-features = false }
@@ -81,7 +80,6 @@ std = [
"hash-db/std",
"sp-std/std",
"serde",
"rustc-hex/std",
"twox-hash/std",
"blake2-rfc/std",
"ed25519-dalek/std",