Skip to content

Commit

Permalink
it is annoying to have a difference between debug and print for hash
Browse files Browse the repository at this point in the history
  • Loading branch information
tamasblummer authored and dongcarl committed Jan 23, 2019
1 parent 8584303 commit 96be35b
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/util/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,15 +326,10 @@ impl serde::Serialize for Sha256dHash {
}
}

// Debug encodings (no reversing)
// Debug encodings
impl fmt::Debug for Sha256dHash {
/// Output the raw sha256d hash, not reversing it (unlike Display and what Core does for user display)
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let &Sha256dHash(data) = self;
for ch in data.iter() {
write!(f, "{:02x}", ch)?;
}
Ok(())
fmt::LowerHex::fmt(self, f)
}
}

Expand Down Expand Up @@ -461,7 +456,7 @@ mod tests {
assert_eq!(format!("{}", Sha256dHash::from_data(&[])),
"56944c5d3f98413ef45cf54545538103cc9f298e0575820ad3591376e2e0f65d");
assert_eq!(format!("{:?}", Sha256dHash::from_data(&[])),
"5df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c9456");
"56944c5d3f98413ef45cf54545538103cc9f298e0575820ad3591376e2e0f65d");
assert_eq!(format!("{:x}", Sha256dHash::from_data(&[])),
"56944c5d3f98413ef45cf54545538103cc9f298e0575820ad3591376e2e0f65d");
assert_eq!(format!("{:X}", Sha256dHash::from_data(&[])),
Expand Down

0 comments on commit 96be35b

Please sign in to comment.