cleanup util::from_hex() (#3265)

* cleanup our from_hex()

* fix keychain tests

* add test coverage for empty hex string
This commit is contained in:
Antioch Peverell
2020-03-10 10:36:18 +00:00
committed by GitHub
parent ee5fe1ac63
commit 8ca381a9c2
18 changed files with 62 additions and 87 deletions
+2 -2
View File
@@ -747,7 +747,7 @@ impl ForeignRpc for Foreign {
) -> Result<BlockHeaderPrintable, ErrorKind> {
let mut parsed_hash: Option<Hash> = None;
if let Some(hash) = hash {
let vec = util::from_hex(hash)
let vec = util::from_hex(&hash)
.map_err(|e| ErrorKind::Argument(format!("invalid block hash: {}", e)))?;
parsed_hash = Some(Hash::from_vec(&vec));
}
@@ -761,7 +761,7 @@ impl ForeignRpc for Foreign {
) -> Result<BlockPrintable, ErrorKind> {
let mut parsed_hash: Option<Hash> = None;
if let Some(hash) = hash {
let vec = util::from_hex(hash)
let vec = util::from_hex(&hash)
.map_err(|e| ErrorKind::Argument(format!("invalid block hash: {}", e)))?;
parsed_hash = Some(Hash::from_vec(&vec));
}