Skip to content

Commit

Permalink
node-data: Print in hash fields in hex format
Browse files Browse the repository at this point in the history
  • Loading branch information
goshawk-3 committed May 16, 2024
1 parent caed8ea commit e977c6b
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions node-data/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ pub mod payload {
CandidateFromHash,
}

#[derive(Debug, Clone, Copy)]
#[derive(Clone, Copy)]
pub enum InvParam {
Hash([u8; 32]),
Height(u64),
Expand All @@ -771,6 +771,15 @@ pub mod payload {
}
}

impl fmt::Debug for InvParam {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Hash(hash) => write!(f, "Hash: {}", to_str(hash)),
Self::Height(height) => write!(f, "Height: {}", height),
}
}
}

#[derive(Default, Debug, Clone, Copy)]
pub struct InvVect {
pub inv_type: InvType,
Expand Down Expand Up @@ -883,11 +892,17 @@ pub mod payload {
}
}

#[derive(Debug, Clone, Default)]
#[derive(Clone, Default)]
pub struct GetBlocks {
pub locator: [u8; 32],
}

impl fmt::Debug for GetBlocks {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "GetBlocks, locator: {}", to_str(&self.locator))
}
}

impl Serializable for GetBlocks {
fn write<W: Write>(&self, w: &mut W) -> io::Result<()> {
w.write_all(&self.locator[..])
Expand Down

0 comments on commit e977c6b

Please sign in to comment.