Merge pull request #529 from zcash/improve-debug-impls

Improve various `Debug` impls
This commit is contained in:
str4d 2022-04-06 21:58:20 +01:00 committed by GitHub
commit 514dfd4ee9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 2 deletions

View File

@ -9,9 +9,18 @@ use zcash_encoding::Vector;
pub use equihash;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
pub struct BlockHash(pub [u8; 32]);
impl fmt::Debug for BlockHash {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// The (byte-flipped) hex string is more useful than the raw bytes, because we can
// look that up in RPC methods and block explorers.
let block_hash_str = self.to_string();
f.debug_tuple("BlockHash").field(&block_hash_str).finish()
}
}
impl fmt::Display for BlockHash {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut data = self.0;

View File

@ -61,9 +61,18 @@ const ZFUTURE_VERSION_GROUP_ID: u32 = 0xFFFFFFFF;
#[cfg(feature = "zfuture")]
const ZFUTURE_TX_VERSION: u32 = 0x0000FFFF;
#[derive(Clone, Copy, Debug, PartialOrd, Ord, PartialEq, Eq, Hash)]
#[derive(Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)]
pub struct TxId([u8; 32]);
impl fmt::Debug for TxId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// The (byte-flipped) hex string is more useful than the raw bytes, because we can
// look that up in RPC methods and block explorers.
let txid_str = self.to_string();
f.debug_tuple("TxId").field(&txid_str).finish()
}
}
impl fmt::Display for TxId {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut data = self.0;