Skip to content

Commit cbe90c5

Browse files
committed
Drop passing now to hold_time
1 parent 53b9810 commit cbe90c5

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

lightning/src/ln/channel.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7500,7 +7500,6 @@ where
75007500
true
75017501
}
75027502
});
7503-
let now = duration_since_epoch();
75047503
pending_outbound_htlcs.retain(|htlc| {
75057504
if let &OutboundHTLCState::AwaitingRemovedRemoteRevoke(ref outcome) = &htlc.state {
75067505
log_trace!(
@@ -7511,7 +7510,7 @@ where
75117510
// We really want take() here, but, again, non-mut ref :(
75127511
match outcome.clone() {
75137512
OutboundHTLCOutcome::Failure(mut reason) => {
7514-
hold_time(htlc.send_timestamp, now).map(|hold_time| {
7513+
hold_time_since(htlc.send_timestamp).map(|hold_time| {
75157514
reason.set_hold_time(hold_time);
75167515
});
75177516
revoked_htlcs.push((htlc.source.clone(), htlc.payment_hash, reason));
@@ -13598,7 +13597,7 @@ where
1359813597
}
1359913598
}
1360013599

13601-
pub(crate) fn duration_since_epoch() -> Option<Duration> {
13600+
fn duration_since_epoch() -> Option<Duration> {
1360213601
#[cfg(not(feature = "std"))]
1360313602
let now = None;
1360413603

@@ -13614,9 +13613,9 @@ pub(crate) fn duration_since_epoch() -> Option<Duration> {
1361413613

1361513614
/// Returns the time expressed in hold time units (1 unit = 100 ms) that has elapsed between send_timestamp and now. If
1361613615
/// any of the arguments are `None`, returns `None`.
13617-
pub(crate) fn hold_time(send_timestamp: Option<Duration>, now: Option<Duration>) -> Option<u32> {
13616+
pub(crate) fn hold_time_since(send_timestamp: Option<Duration>) -> Option<u32> {
1361813617
send_timestamp.and_then(|t| {
13619-
now.map(|now| {
13618+
duration_since_epoch().map(|now| {
1362013619
let elapsed = now.saturating_sub(t).as_millis() / HOLD_TIME_UNIT_MILLIS;
1362113620
u32::try_from(elapsed).unwrap_or(u32::MAX)
1362213621
})

lightning/src/ln/channelmanager.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,10 @@ use crate::ln::chan_utils::selected_commitment_sat_per_1000_weight;
6060
// Since this struct is returned in `list_channels` methods, expose it here in case users want to
6161
// construct one themselves.
6262
use crate::ln::channel::{
63-
self, hold_time, Channel, ChannelError, ChannelUpdateStatus, FundedChannel, InboundV1Channel,
64-
OutboundV1Channel, ReconnectionMsg, ShutdownResult, UpdateFulfillCommitFetch,
65-
WithChannelContext,
63+
self, hold_time_since, Channel, ChannelError, ChannelUpdateStatus, FundedChannel,
64+
InboundV1Channel, OutboundV1Channel, PendingV2Channel, ReconnectionMsg, ShutdownResult,
65+
UpdateFulfillCommitFetch, WithChannelContext,
6666
};
67-
use crate::ln::channel::{duration_since_epoch, PendingV2Channel};
6867
use crate::ln::channel_state::ChannelDetails;
6968
use crate::ln::inbound_payment;
7069
use crate::ln::msgs;
@@ -8299,8 +8298,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
82998298
RAAMonitorUpdateBlockingAction::from_prev_hop_data(&hop_data);
83008299

83018300
// Obtain hold time, if available.
8302-
let now = duration_since_epoch();
8303-
let hold_time = hold_time(send_timestamp, now).unwrap_or(0);
8301+
let hold_time = hold_time_since(send_timestamp).unwrap_or(0);
83048302

83058303
// If attribution data was received from downstream, we shift it and get it ready for adding our hold
83068304
// time. Note that fulfilled HTLCs take a fast path to the incoming side. We don't need to wait for RAA

0 commit comments

Comments
 (0)