Merge pull request #1600 from TheBlueMatt/2022-07-explicit-avoid-retries
[rust-lightning] / lightning / src / routing / gossip.rs
index 736d2f0580002db9fed2957e99c6c22e4994b8ed..10ce74b971e6eebd13054257826aa78cbec94276 100644 (file)
@@ -745,13 +745,13 @@ impl<'a> DirectedChannelInfo<'a> {
                let (htlc_maximum_msat, effective_capacity) = match (htlc_maximum_msat, capacity_msat) {
                        (Some(amount_msat), Some(capacity_msat)) => {
                                let htlc_maximum_msat = cmp::min(amount_msat, capacity_msat);
-                               (htlc_maximum_msat, EffectiveCapacity::Total { capacity_msat })
+                               (htlc_maximum_msat, EffectiveCapacity::Total { capacity_msat, htlc_maximum_msat: Some(htlc_maximum_msat) })
                        },
                        (Some(amount_msat), None) => {
                                (amount_msat, EffectiveCapacity::MaximumHTLC { amount_msat })
                        },
                        (None, Some(capacity_msat)) => {
-                               (capacity_msat, EffectiveCapacity::Total { capacity_msat })
+                               (capacity_msat, EffectiveCapacity::Total { capacity_msat, htlc_maximum_msat: None })
                        },
                        (None, None) => (EffectiveCapacity::Unknown.as_msat(), EffectiveCapacity::Unknown),
                };
@@ -816,10 +816,6 @@ impl<'a> DirectedChannelInfoWithUpdate<'a> {
        /// Returns the [`EffectiveCapacity`] of the channel in the direction.
        #[inline]
        pub(super) fn effective_capacity(&self) -> EffectiveCapacity { self.inner.effective_capacity() }
-
-       /// Returns the maximum HTLC amount allowed over the channel in the direction.
-       #[inline]
-       pub(super) fn htlc_maximum_msat(&self) -> u64 { self.inner.htlc_maximum_msat() }
 }
 
 impl<'a> fmt::Debug for DirectedChannelInfoWithUpdate<'a> {
@@ -850,6 +846,8 @@ pub enum EffectiveCapacity {
        Total {
                /// The funding amount denominated in millisatoshi.
                capacity_msat: u64,
+               /// The maximum HTLC amount denominated in millisatoshi.
+               htlc_maximum_msat: Option<u64>
        },
        /// A capacity sufficient to route any payment, typically used for private channels provided by
        /// an invoice.
@@ -869,7 +867,7 @@ impl EffectiveCapacity {
                match self {
                        EffectiveCapacity::ExactLiquidity { liquidity_msat } => *liquidity_msat,
                        EffectiveCapacity::MaximumHTLC { amount_msat } => *amount_msat,
-                       EffectiveCapacity::Total { capacity_msat } => *capacity_msat,
+                       EffectiveCapacity::Total { capacity_msat, .. } => *capacity_msat,
                        EffectiveCapacity::Infinite => u64::max_value(),
                        EffectiveCapacity::Unknown => UNKNOWN_CHANNEL_CAPACITY_MSAT,
                }
@@ -1647,6 +1645,11 @@ impl ReadOnlyNetworkGraph<'_> {
                &*self.channels
        }
 
+       /// Returns information on a channel with the given id.
+       pub fn channel(&self, short_channel_id: u64) -> Option<&ChannelInfo> {
+               self.channels.get(&short_channel_id)
+       }
+
        /// Returns all known nodes' public keys along with announced node info.
        ///
        /// (C-not exported) because we have no mapping for `BTreeMap`s
@@ -1654,6 +1657,11 @@ impl ReadOnlyNetworkGraph<'_> {
                &*self.nodes
        }
 
+       /// Returns information on a node with the given id.
+       pub fn node(&self, node_id: &NodeId) -> Option<&NodeInfo> {
+               self.nodes.get(node_id)
+       }
+
        /// Get network addresses by node id.
        /// Returns None if the requested node is completely unknown,
        /// or if node announcement for the node was never received.