From: Jeffrey Czyz Date: Fri, 28 Jan 2022 14:13:01 +0000 (-0600) Subject: f - Custom Debug implementations X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=a7c7c34072c3751a7d3c40cdaf549e811d417faf;p=rust-lightning f - Custom Debug implementations --- diff --git a/lightning/src/routing/network_graph.rs b/lightning/src/routing/network_graph.rs index 1affc960f..66c656155 100644 --- a/lightning/src/routing/network_graph.rs +++ b/lightning/src/routing/network_graph.rs @@ -697,7 +697,7 @@ impl_writeable_tlv_based!(ChannelInfo, { /// A wrapper around [`ChannelInfo`] representing information about the channel as directed from a /// source node to a target node. -#[derive(Clone, Debug)] +#[derive(Clone)] pub struct DirectedChannelInfo<'a> { channel: &'a ChannelInfo, direction: Option<&'a ChannelUpdateInfo>, @@ -749,8 +749,18 @@ impl<'a> DirectedChannelInfo<'a> { } } +impl<'a> fmt::Debug for DirectedChannelInfo<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + f.debug_struct("DirectedChannelInfo") + .field("source", &self.source) + .field("target", &self.target) + .field("channel", &self.channel) + .finish() + } +} + /// A [`DirectedChannelInfo`] with [`ChannelUpdateInfo`] available in its the direction. -#[derive(Clone, Debug)] +#[derive(Clone)] pub(super) struct DirectedChannelInfoWithUpdate<'a> { inner: DirectedChannelInfo<'a>, } @@ -769,6 +779,12 @@ impl<'a> DirectedChannelInfoWithUpdate<'a> { pub(super) fn effective_capacity(&self) -> EffectiveCapacity { self.inner.effective_capacity() } } +impl<'a> fmt::Debug for DirectedChannelInfoWithUpdate<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + self.inner.fmt(f) + } +} + /// The effective capacity of a channel for routing purposes. /// /// While this may be smaller than the actual channel capacity, amounts greater than