Skip to content

Commit 85eb1fd

Browse files
committed
Avoid returning a reference to a u64.
In c353c3e an accessor method was added which returns an `Option<&u64>`. While this allows Rust to return an 8-byte object, returning a reference to something pointer-sized is a somewhat strange API. Instead, we opt for a straight `Option<u64>`, which is sadly somewhat larger on the stack, but is simpler and already supported in the bindings generation.
1 parent 4910c7c commit 85eb1fd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lightning-invoice/src/payment.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,8 +741,8 @@ pub struct InFlightHtlcs(HashMap<(u64, bool), u64>);
741741
impl InFlightHtlcs {
742742
/// Returns liquidity in msat given the public key of the HTLC source, target, and short channel
743743
/// id.
744-
pub fn used_liquidity_msat(&self, source: &NodeId, target: &NodeId, channel_scid: u64) -> Option<&u64> {
745-
self.0.get(&(channel_scid, source < target))
744+
pub fn used_liquidity_msat(&self, source: &NodeId, target: &NodeId, channel_scid: u64) -> Option<u64> {
745+
self.0.get(&(channel_scid, source < target)).map(|v| *v)
746746
}
747747
}
748748

0 commit comments

Comments
 (0)