Merge pull request #2042 from ffaex/add_fn

added fn_add_htlc
This commit is contained in:
Matt Corallo 2023-07-08 21:47:48 +00:00 committed by GitHub
commit 0d3adb8fa0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -204,6 +204,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> {