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
@@ -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")