Skip to content

Commit 2f811f3

Browse files
committed
Change InFlightHtlcs to a tuple struct
1 parent c5206b3 commit 2f811f3

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

lightning-invoice/src/payment.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -740,25 +740,22 @@ where
740740
}
741741
}
742742

743-
/// Data structure used to track information about inflight HTLCs.
744-
pub struct InFlightHtlcs {
745-
/// A map with liquidity value (in msat) keyed by a short channel id and the direction the HTLC
746-
/// is traveling in. The direction boolean is determined by checking if the HTLC source's public
747-
/// key is less than its destination. See [`InFlightHtlcs::used_liquidity_msat`] for more
748-
/// details.
749-
pub map: HashMap<(u64, bool), u64>
750-
}
743+
/// A map with liquidity value (in msat) keyed by a short channel id and the direction the HTLC
744+
/// is traveling in. The direction boolean is determined by checking if the HTLC source's public
745+
/// key is less than its destination. See [`InFlightHtlcs::used_liquidity_msat`] for more
746+
/// details.
747+
pub struct InFlightHtlcs(HashMap<(u64, bool), u64>);
751748

752749
impl InFlightHtlcs {
753750
/// Creates a new instance with an optional map of liquidity information.
754-
pub fn new(map: Option<HashMap<(u64, bool), u64>>) -> Self {
755-
InFlightHtlcs { map: map.unwrap_or(HashMap::new()) }
751+
pub fn new(used_liquidity_msat: Option<HashMap<(u64, bool), u64>>) -> Self {
752+
InFlightHtlcs(used_liquidity_msat.unwrap_or(HashMap::new()))
756753
}
757754

758755
/// Returns liquidity in msat given the public key of the HTLC source, target, and short channel
759756
/// id.
760757
pub fn used_liquidity_msat(&self, source: &NodeId, target: &NodeId, channel_scid: u64) -> Option<&u64> {
761-
self.map.get(&(channel_scid, source < target))
758+
self.0.get(&(channel_scid, source < target))
762759
}
763760
}
764761

0 commit comments

Comments
 (0)