Skip to content

Commit 4833942

Browse files
committed
feat(dmq): add hex DMQ message id in debug formatting
1 parent 38d397c commit 4833942

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/mithril-dmq/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ anyhow = { workspace = true }
1919
async-trait = { workspace = true }
2020
bincode = { version = "2.0.1" }
2121
blake2 = "0.10.6"
22+
hex = { workspace = true }
2223
mithril-cardano-node-chain = { path = "../cardano-node/mithril-cardano-node-chain" }
2324
mithril-common = { path = "../../mithril-common" }
2425
pallas-codec = { version = "0.34.0" }

internal/mithril-dmq/src/model/message.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use pallas_network::miniprotocols::localmsgsubmission::DmqMsg;
55
use serde::{Deserialize, Deserializer, Serialize, Serializer};
66

77
/// Wrapper for a DMQ message which can be serialized and deserialized.
8-
#[derive(Debug, Clone, PartialEq, Eq)]
8+
#[derive(Clone, PartialEq, Eq)]
99
pub struct DmqMessage(DmqMsg);
1010

1111
#[derive(Serialize, Deserialize)]
@@ -70,6 +70,17 @@ impl<'de> Deserialize<'de> for DmqMessage {
7070
}
7171
}
7272

73+
impl std::fmt::Debug for DmqMessage {
74+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
75+
write!(
76+
f,
77+
"DmqMessage(id: {}, msg: {:?})",
78+
hex::encode(&self.msg_payload.msg_id),
79+
self.msg_payload
80+
)
81+
}
82+
}
83+
7384
#[cfg(test)]
7485
mod tests {
7586
use pallas_network::miniprotocols::localmsgsubmission::{
@@ -82,7 +93,12 @@ mod tests {
8293
fn test_dmq_message_serialize_deserialize() {
8394
let dmq_msg = DmqMsg {
8495
msg_payload: DmqMsgPayload {
85-
msg_id: vec![0, 1],
96+
msg_id: vec![
97+
253, 111, 24, 132, 36, 83, 113, 4, 132, 74, 241, 66, 114, 193, 163, 53, 35, 86,
98+
249, 154, 135, 189, 75, 219, 6, 153, 202, 132, 243, 164, 21, 224, 85, 56, 190,
99+
59, 62, 14, 115, 123, 156, 95, 171, 144, 157, 161, 160, 224, 47, 200, 68, 8,
100+
226, 150, 234, 230, 72, 30, 67, 71, 7, 228, 22, 187,
101+
],
86102
msg_body: vec![0, 1, 2],
87103
kes_period: 10,
88104
expires_at: 100,

0 commit comments

Comments
 (0)