From: ff Date: Mon, 20 Feb 2023 16:38:29 +0000 (+0100) Subject: Added a function which adds inflight HTLCs to InFlightHtlcs-struct, X-Git-Tag: v0.0.116-rc1~12^2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=b9274e5fcced3cadff927ec2c7e28a2fa2ffe0a2;p=rust-lightning Added a function which adds inflight HTLCs to InFlightHtlcs-struct, 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 --- diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index 09cee2a2e..57ac6a78a 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -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 {