]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Added a function which adds inflight HTLCs to InFlightHtlcs-struct,
authorff <ff@fyodor.de>
Mon, 20 Feb 2023 16:38:29 +0000 (17:38 +0100)
committerff <ff@fyodor.de>
Thu, 23 Feb 2023 21:06:40 +0000 (22:06 +0100)
which is used by router

One would use that function if he would get data from for example
c-lightning lightning.readthedocs.io/lightning-listhtlcs.7.html
and would like to use that with ldk's router

lightning/src/routing/router.rs

index 09cee2a2e84e8b8acb2d63842c2ed054d387e9ee..57ac6a78afa2bcca8a0d040edbffa69470f53115 100644 (file)
@@ -218,6 +218,15 @@ impl InFlightHtlcs {
                }
        }
 
+       /// Adds a known HTLC given the public key of the HTLC source, target, and short channel
+       /// id.
+       pub fn add_inflight_htlc(&mut self, source: &NodeId, target: &NodeId, channel_scid: u64, used_msat: u64){
+               self.0
+                       .entry((channel_scid, source < target))
+                       .and_modify(|used_liquidity_msat| *used_liquidity_msat += used_msat)
+                       .or_insert(used_msat);
+       }
+
        /// Returns liquidity in msat given the public key of the HTLC source, target, and short channel
        /// id.
        pub fn used_liquidity_msat(&self, source: &NodeId, target: &NodeId, channel_scid: u64) -> Option<u64> {