]> git.bitcoin.ninja Git - rust-lightning/commitdiff
f - Custom Debug implementations
authorJeffrey Czyz <jkczyz@gmail.com>
Fri, 28 Jan 2022 14:13:01 +0000 (08:13 -0600)
committerJeffrey Czyz <jkczyz@gmail.com>
Mon, 31 Jan 2022 21:11:37 +0000 (15:11 -0600)
lightning/src/routing/network_graph.rs

index 1affc960fc89ea17fe6642eb8f059035b31f2df9..66c656155617a5ef543405f61089ff6fddf1d17f 100644 (file)
@@ -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